Skip to content

Instantly share code, notes, and snippets.

@jnslxndr
Created January 7, 2011 13:55
Show Gist options
  • Save jnslxndr/769477 to your computer and use it in GitHub Desktop.
Save jnslxndr/769477 to your computer and use it in GitHub Desktop.
Using sed to rename files in more or less one line ;)
# for example ".bak"
TOKEN=.bak
ETOKEN=`echo $TOKEN |sed 's/\./\\\./'`
# any suggestions how to get rid of this "bash" at the end are appreciated
# also: alternatively there is a NOT opperator on sed's regex - not used here
find . -path "*$TOKEN" -d 1 |sed 's/^\.\(.*\)\($ETOKEN\)$/mv `pwd`\1\2 `pwd`\1/'|bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment