[NTLUG:Discuss] batch file rename
Bobby Wrenn
bobby at wrennest.com
Fri Sep 19 09:01:59 CDT 2014
I copied and pasted your code into my shell script (below). I was
working in a backup directory so no harm. Running the script deleted all
the files in the directory. I tried it with only one file in the
directory. Same result.
#!/bin/bash
for i in *.mp3
do
IFS="${IFS}-." set $i
mv $i $4$2$3.mp3
done
On 09/19/2014 03:37 AM, Rusty Haddock wrote:
> Bobby Wrenn wrote:
> >I took out the extra "sed" and escaped the "+". No error but the script
> >just executes and never exits. Nothing happens.
> >
> >No on line examples that I found addressed this kind of transposition in
> >the file name. Any other ideas, anyone?
>
> This worked for me for changing filesd like CCC-05-15-2014.mp3 to
> 20140515.mp3:
>
> for i in *.mp3
> do
> IFS="${IFS}-." set $i
> mv $i $4$2$3.mp3
> done
>
> -Rusty-
More information about the Discuss
mailing list