Productive? Bulk rename of files

Recently our one ios developer got the bunch(around 50) of graphics from a designer. For specific reason developer wanted to rename all graphics files. I was analysing the names of all filenames and developer wanted to remove “@2x” substring from the names of all graphics file. The very first solution that came to my mind was to write a quick 3 lines of shell script for this. I did start writing the script 😛

Here is the script that looks for substring in name and replace with desire input. We just copied to the folder of those graphics files and ran the script from terminal. It works. No need to manually renaming every files.

for i in ./*@2x*; do 
	mv -- "$i" "${i//@2x/}";

Be the first to leave a comment. Don’t be shy.

Join the Discussion

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>