Batch Renaming

If you need to rename a bunch of files from, for example,|add.png| to|add_32.png|, just do the following:
for i in *; do j=`echo $i | cut -d . -f 1`; j=$j"_32.png"; mv $i $j; done
Basically, this says "/for every file in the folder, cut the filename on all dots and take the first result into variable '|j|'. Then append '|_32.png|' onto the end of the variable. Finally move the original file to the new filename/".
for i in * ; do j=`echo $i | sed 's#searchstring#replacestring#g' - ` ; mv "$i" "$j" ; done
Change searchstring and replacestring for whatever you want to replace. If a file is missing this searchstring, then you will get an error for that file and nothing will happen to it. This one works recursively:
for i in `find` ; do j=`echo $i | sed 's/searchstring/replacestring/g' -` ; mv "$i" "$j" ; done
The only change is the initial file gathering, from "*" to "`find`".

Popular posts from this blog

Künefe Tarifi

Bir Word Belgesinde Kapak Harici Kaç sayfa Olduğunu Bulmak