Hi,
I apologise for creating yet another batch rename thread, I know that there is a lot of information on it and I have attempted for a couple hours to find a solution using google and other threads. If I missed a suitable answer I apologise ahead of time.
I would like to use only one liners from my bash command window.
I have a bunch of files that were named with periods as separators. I used the following command to remove the periods and tweak a few other things.
Original filename:
Code:
get.smart.1965.s01e01.Mr.Big.dvdrip.xvid-fqm.avi
Current filename:
Code:
Get_Smart_(1965)_01e01_Mr_Big.avi
Desired filename:
Code:
Get Smart (1965) 01e01 - Mr Big.avi
I have been trying to use this command so that I can replace the fourth instance of '_' with '-' but a lot of commands give me errors while they seem to be working for other people. I have bash, sed, awk, gawk and perl installed and am using Cygwin on Windows XP. I cannot use simple matching as I did previously because the number preceding the dash will be different for each file.
Code:
ls *.avi | awk '{print("mv "$1" "$1)}' | sed 's/\_/\-/4'|/bin/sh
This previews what the command will do if you remove the |/bin/sh and the preview shows the correct operation. However when I append the |/bin/sh to actually execute it, I get this error:
Code:
syntax error near unexpected token `('
Finally, along the same lines, when I am ready to remove the '_' and replace it with spaces, I can use the command
as I did to make the first set of changes above. I noticed that this command seems to only change the first instance and I have to run it multiple times to remove all of them. How can I make this apply to all pattern instances?
Thanks in advance.