Batch rename jpg after EXIF data

On this website I read an interesting solution when you want the linux creation data to be the same as the date in the exif data.

But I modified the tool a bit to suit my needs: Copy and paste in Gedit, and save as exifrename.sh in the directory where you want to change the filedata. Make the file executable and execute it by double clicking in nautilus. Now you can see it changeing life in your filemanager.

find -name '*.jpg' | while read PIC; do

DATE=$(exiftool -p '$Createdate' $PIC | sed 's/[: ]//g')

touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC

#mv -i $PIC $(dirname $PIC)/$DATE.jpg

#I removed this line since I didn't want to move the files.

done

The original author wrote this,

There are several programs capable of working with EXIF data. My favourite is ExifTool (www.sno.phy.queensu.ca/~phil/exiftool). ExifTool can read and manipulate just about any EXIF information, including extracting the Date/Time Original or Create Data EXIF tags. You can use this information to rename the files or change their timestamps. For example:

find -name '*.jpg' | while read PIC; do DATE=$(exiftool -p '$DateTimeOriginal' $PIC | sed 's/[: ]//g') touch -t $(echo $DATE | sed 's/\(..$\)/\.\1/') $PIC mv -i $PIC $(dirname $PIC)/$DATE.jpg done

The first line finds all *.jpg files in the current directory and below. The next extracts the Date/Time Original tag from each file (you may need to use Create Data instead, depending on your camera) and removes the spaces and colons. The next line sets the file's timestamp to this date the horrible looking sed regular expression is necessary to insert a dot before the final two characters, because the touch command expects the seconds to be separated from the rest of the time string like this. The final command renames the file, using the -i option to mv in case two files have the same timestamp. This will stop any files being overwritten.

When you don't have good EXIF data in the files, than a simple redate command can be used with the touch command. Open the terminal in the appropriate folder and type:

touch *.jpg -d 20180125

for make the file date 2018 jan 25th

The solution to your duplicates problem is a program called fdupes (available from http://netdial.caribe.net/~adrian2/fdupes.html or as an RPM for FC6). This compares the contents of files, so it will find duplicates even if they have different names and timestamps.

fdupes --recurse ~/photos

will list all duplicate files in your photos directory. There are also options that you can use to delete the duplicates:

fdupes --recurse --omitfirst --sameline ~/photos | xargs rm

Be careful of any option that automatically deletes files. Run without deletion first so you can see what's going to happen.

There is also another program that can be used to rename thje files after theit exif data. You'll find it here.

http://ceicer.org/exifrename/index_eng.php