Skip to content

Instantly share code, notes, and snippets.

@shammellee
Created September 29, 2016 10:07
Show Gist options
  • Save shammellee/d98f276401517e030a7072f2927e47bc to your computer and use it in GitHub Desktop.
Save shammellee/d98f276401517e030a7072f2927e47bc to your computer and use it in GitHub Desktop.
rename files from a hash of file name mappings
#! /usr/bin/env bash
manifest=${1:-manifest}
[ ! -f "$manifest" ] && echo "no file \"${manifest}\"" && exit 1
while read line
do
from=${line%%:*}
to=${line##*:}
if [ -e "$from" ] && [ ! -e "$to" ]
then
echo "${from} -> ${to}"
mv "$from" "$to"
else
echo "no file \"${from}\" or \"${to}\" already exists"
fi
done < "$manifest"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment