Wednesday 28 October 2015

Rename multiple files on Mac

Surprisingly I found it difficult to rename a bunch of files on the commandline. After research some time I came up with the following

I want to rename files recursively  like


./org/inb/bsc/xpointer/PointerPart.java?format=raw

into 

./org/inb/bsc/xpointer/PointerPart.java


find . -name "*raw" -exec sh -c 'mv {} "${0/\?format=raw/}"' {} \;