Frank Steinmetzger wrote: > Am Tue, Nov 22, 2022 at 03:59:27AM -0600 schrieb Dale: > >>> If you still want to stick to a terminal solution akin to mv, then there is >>> no way around a little script which wraps mv by extracting the extension and >>> filename base. You could also add some “intelligence” with regards to >>> directories, in order to reduce the amount of effort required to use the >>> command—in case your directories follow some schema or are constant. >>> >>> >>> #!/usr/bin/sh >>> >>> [ "$#" -ne "2" ] && exit 1 >>> SRC="$1" >>> DST="$2" >>> >>> SRC_EXT="${SRC##*.}" >>> DST_BASE="${DST%.*}" >>> >>> # remove destination for the case that the extensions differ >>> rm "$DST" >>> >>> mv "$SRC" "${DST_BASE}${SRC_EXT}" >>> >> I finally got a chance to try this. I saved it and made it executable. >> It runs but gave me this error. >> >> >> dmv torrent/video_name-old-place.mp4 video-name-new-place.mp4 >> bash: /bin/dmv: /usr/bin/sh: bad interpreter: No such file or directory >> dale@fireball ~/Desktop/Crypt/Series $ >> >> >> My scripting skills are minimal at best. Still, I kinda got what your >> script was doing. Those who have known me for a while understand how >> miraculous that is. ROFL I did some googling. It seems to not be able >> to find the 'shebang' part. Sure enough, sh isn't located in /usr/bin >> here. It's in /bin tho. I edited that line so it can find it. When I >> tried it, it worked but noticed another problem. […] > Well, it would have been boring to provide you with a turn-key solution. ;-) > Congrats on getting it working. In my Arch setup, sh is in /usr/bin. A > flexible solution is to use #!/usr/bin/env sh, which looks the command up > before executing it. > >> I added a little . on that last line before the extension bit. I'm a >> happy camper. > Give me a nudge if you want the more luxurious version with interactive > selection of the overwrite destination. I think I already started a > prototype somewhere, but can’t find it right now. >
Feel free to share. Even if I don't use it, someone else may find it and make good use of it. It's one reason I posted the corrected version and why I changed what I did. Someone else just may run up on this and find it helpful as well. If possible and you have time, describe a bit what each part does. Usually when I do this, I have several videos, anywhere from 10 to sometimes 30 or more. Sometimes I wish it could 'detect' which new one goes with which old one. Thing is, I don't know if a script can do this or not. Sometimes the new is named pretty different from the old. I don't think a script could do it reliably. If things were more consistent, maybe, but there is a lot of differences at times. Your scripts at least keeps the extension correct without adding any more effort on my part, except having to type dmv instead of mv. I chose d since the first letter of my name is d. It was something. lol The current script sure is handy tho. Dale :-) :-)