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