Created
October 5, 2008 09:25
-
-
Save coreyti/14867 to your computer and use it in GitHub Desktop.
Converts DSC_NNNN.JPG to something like 2008.Jan.01_NNNN.jpg, where the date prefix is derived from the file modification date
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 | |
############################################################################### | |
# Nikon image filename conversion, e.g. (DSC_NNNN.JPG to 2008.Jan.01_NNNN.jpg) | |
############################################################################### | |
# change any spaces to underscores | |
for i in * ; do | |
if [ -f "$i" ] ; then | |
echo mv \"$i\" ${i// /_} | |
fi | |
done | |
# lowercase the extension | |
for i in `ls -1 *.JPG` ; do echo mv $i ${i%.*}.jpg | sh ; done | |
# change DSC prefix to date prefix | |
for i in `ls -1 DSC*` ; do prefix=`ls -lT $i | awk '{print $9"."$6"."$7}'` ; suffix=`echo ${i#*_}` ; echo mv {DSC,$prefix}"_"$suffix | sh ; done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment