Skip to content

Instantly share code, notes, and snippets.

@samir
Created November 24, 2010 21:03
Show Gist options
  • Save samir/714407 to your computer and use it in GitHub Desktop.
Save samir/714407 to your computer and use it in GitHub Desktop.
Renaming files in one line
# Rename files in one line
# Util for renaming files with prefix or sufix, removing, modifying, etc
# First, list files that will be renamed
# In sequence, create the command to rename it (using mv command)
# Modify the command swapping the string
# Send it to /bin/bash
ls *_abc.png | awk '{print("mv "$1" "$1)}' | sed 's/_abc/_def/2' | /bin/bash
# Credits: http://hints.macworld.com/article.php?story=20010509130450691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment