New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Help with renaming filnames in bulk
Hi there,
I have been searching for a way to rename file names in my box(not good at making a script) . the scenario is this. I have many zipped files , which have a names like : filename1(ahmiq).zip , filename2(ahmiq).zip , so i wish to rename all those files which have (ahmiq) in them with a _a or something like that e-g , filename1_file.zip , filename2_file.zip.
may be something like If filename matches (ahmiq) , mv it with _file.. If someone could get a few minutes and help me out with it , will be very thankful .
regards
Comments
Though I don't have much experience with it, the Linux
rename
command is designed for just such a purpose, and has extensive options with how to select files to rename, and what to rename them to.tx , looking onto it
mv $file "$( echo $file | cut -d '(' -f1 )_file.zip"
done
works flawleslly , thanks
haha about to watch it
Haha.
Good now only for future reference, but with the rename command @dstrout mentions you can simply:
rename 's/(ahmiq)/_file/' *
which is both less fiddily and more powerful if you can do regex. If you're not confident then -n will allow you to experiment without actually renaming anything