Created
July 14, 2011 23:59
-
-
Save jagipson/1083757 to your computer and use it in GitHub Desktop.
JPG Renamer
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
#!/bin/bash | |
basedir=/tmp/testscript/working/Images | |
pushd "$basedir" &>/dev/null | |
# Loop over all dirs with names in front | |
for dirname in $(find ./apteryx -maxdepth 1 -type d -iregex '\./[a-z].*') | |
do | |
patnum=$(echo $dirname | sed 's/^.*_\([0-9]\+\)/\1/') | |
if grep -qv '^[[:digit:]]\+$' <<<$patnum | |
then | |
echo "Warning: error parsing directory $dirname, got '$patnum'; skipping" | |
continue | |
elif [[ ! -d "$patnum" ]] | |
then | |
echo "Warning: unable to find destination folder $basedir/$patnum" | |
continue | |
else | |
set -o xtrace | |
find $patnum -regextype posix-awk -iregex .*/[0-9]{2}-[0-9]{2}-[0-9].*.jpg -type f # -exec ln {} ./apteryx/$dirname/ \; | |
set +o xtrace | |
fi | |
done | |
popd &>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
find /tmp/testscript/ -type f