#!/bin/bashSo, if i have a filename with a.xxx.01.avi and i wanted to remove the xxx part, i only need to execute the script and every file with that pattern will be changed to a.01.avi.
LS=`ls *`
for FILE in $LS
do
name=`ls $FILE | cut -d . -f1`
name1=`ls $FILE | cut -d . -f3`
name2=`ls $FILE | cut -d . -f4`
mv $FILE "$name.$name1.$name2"
done
Simple huh? BASH
Thanks for sharing... never used bash yet...
ReplyDeleteNice work, but also check out the rename command...not sure if it could have done what you wanted, but it's pretty good!
ReplyDelete[grdryn@localhost ~]$ rename
rename: not enough arguments
Usage:
rename [options] expression replacement file...
Options:
-v, --verbose explain what is being done
-V, --version output version information and exit
-h, --help display this help and exit
Yes, that's also possible, but for lots of files, we still need scripting :)
ReplyDeleterename 's/\.xxx//g' *avi
ReplyDeleteWould do the same.