Created
September 29, 2016 10:07
-
-
Save shammellee/d98f276401517e030a7072f2927e47bc to your computer and use it in GitHub Desktop.
rename files from a hash of file name mappings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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