Skip to content

Instantly share code, notes, and snippets.

@cab404
Last active April 12, 2016 19:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cab404/b0c82e26fa695eaaea88ceb0023d1dff to your computer and use it in GitHub Desktop.
Save cab404/b0c82e26fa695eaaea88ceb0023d1dff to your computer and use it in GitHub Desktop.
#!/bin/bash
# Simple sed-based file renamer
if [[ $1 == "" ]]; then
echo "No sed expression specified"
exit 0
fi
DATA=$(ls -1q); IFS=$'\n';
for A in $DATA; do
B=$(echo "$A" | sed -e "$1")
if [[ $A != $B ]]; then
echo "$A -> $B"
mv "$A" "$B"
fi
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment