Oliver Nassar

Mass svn rename for files

December 09, 2010

Ran into a hurdle whereby I needed to convert maybe 30+ xml files to a JSON extension. But I needed to run them through svn mv rather than just a mv statement.

After a bit of help and playing around found this gem:

for file in *.xml;
   do svn mv $file `basename $file xml`json;
done;

This simply loops through the xml files in the directory, strips out the extension via the basename program/application/utility, appends the JSON extension and svn mv's it.

I heart bash.