Determine filetype based on exif data?

Started by arsenius, June 09, 2011, 07:38:08 AM

Previous topic - Next topic

arsenius

I have a failed iPhone backup from which I would like to recover my photos and videos.  It is about 12GB.  Because of the way iTunes handles backups, none of the files have any file extensions.

I would like to use exiftool to assign a new filename to each file, including the file extension.  I tried doing something like listed in the section "Renaming and/or Moving Files" replacing %%e with .jpg, but it did not open any of the files saying that there were no images.  I am guessing that is because none of the images in the backup directory have extensions.

Is there a way to use exiftool to do what I want?  Ideally I would like to input a directory and have exiftool identify both the movie files (should be m4v?) and the images (png and jpg) and move them to a new directory while giving them an appropriate extension based on the exif information.  The other files (mostly sqllite) would be ignored.

Is this possible?  Or will I need to give extensions to everything first?

Phil Harvey

You could try something like this:

exiftool '-filename<$filename.$filetype' DIR/*

where DIR is the directory containing the images.

(note: use double quotes instead of single quotes if you are running Windows)

If the extensions aren't exactly what you want, you can set them individually to whatever you want like this:

exiftool '-filename<$filename.jpg' -if '$filetype eq "JPEG"' DIR/*

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

arsenius

Quote from: Phil Harvey on June 09, 2011, 07:46:22 AM
You could try something like this:

exiftool '-filename<$filename.$filetype' DIR/*

where DIR is the directory containing the images.

(note: use double quotes instead of single quotes if you are running Windows)

If the extensions aren't exactly what you want, you can set them individually to whatever you want like this:

exiftool '-filename<$filename.jpg' -if '$filetype eq "JPEG"' DIR/*

- Phil

Thank you for your fast reply!  I finally got around to trying it last night, and it worked perfectly!  It even located and found the plist and zip files (which I have no use for, but cool anyways).