Monday, November 8, 2010

batch file rename in ubuntu

batch file rename in ubuntu:


example got 100 file like this:
backupfile1disember2009.mp4
backupfile2disember2009.mp4
backupfile3disember2009.mp4
need to change to:
01disember2009.mp4
02disember2009.mp4
03disember2009.mp4
solution:
for i in * ; do j=`echo $i | sed 's#backupfile#0#g' - ` ; mv "$i" "$j" ; done
thats all.
source:
for i in * ; do j=`echo $i | sed 's#searchstring#replacestring#g' - ` ; mv "$i" "$j" ; done
from:
http://www.thingy-ma-jig.co.uk/blog/19-04-2008/how-batch-rename-files

No comments:

Post a Comment