add extension to extension-less files.

Started by bilalalthaf, June 19, 2014, 05:34:12 PM

Previous topic - Next topic

bilalalthaf

Dear Phil Harvey,

Please help me on this matter. I have a set of files which do not have extensions. I am able to identify the filetypes manually by dragging and dropping onto the exiftool command.

I want to rename the files automatically by identifying. Is it possible? please help

Phil Harvey

You could try this:

exiftool "-filename<$filename.$filetype" *

Note that the double quotes I used are for Windows.  Use single quotes instead if you are on Mac or Linux.

This command will add an extension to all recognized files in the current directory.  The only problem is that the FileType reported by ExifTool is not always in the form of an extension.  But for most file types this will do something reasonable.

If you want to tweak the result, you can use an advanced formatting expression.  For example, to use "JPG" instead of "JPEG", do this:

exiftool "-filename<$filename.${filetype;s/JPEG/JPG/}" *

- 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 ($).

bilalalthaf

Thank you so much for your quick reply and solution.

I got the file extensions to all my files.

Wanted to know can i get the file name to be the creation date of the file?

I kept on searching the forum and i found out some tweaks..

I used this exiftool "-FileName<MediaCreateDate" -ext jpeg -d "%Y%m%d_%H%M%S.%%e" "F:\June 14 Backup\Pictures/*"

and got the files to rename to the Year/Date/Time format..

But in majority of the files the Creation date is not found. Why would it be the reason? Lack of exit data?

bilalalthaf

I'm not able to get the Creation Date of any audio file  :(

The Media Creation Date in this Exif is correct. But how do i get the files renamed to that?

You must've already figured that im a total newbie

Phil Harvey

Use this command to determine what date/time information your file contains:

exiftool -a -G1 -s -time:all FILE

Then use one of these tags instead of MediaCreateDate when renaming your files.

- 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 ($).

bilalalthaf

OK. I GOT THE TIME I WANT TO CHANGE IT TO. PLEASE HELP ME ON HOW I SHOULD USE THE PARTICULAR TAG.

FOR EXAMPLE SEE THIS SCREENSHOT. I WANT TO USE THE "TRACKCREATEDATE" IN THAT FILE.

bilalalthaf

Sir one more question.

I have assorted all the audio files to one folder. All the audio in the backup have come to one folder. All applications audio, recordings, mail attachments.

Now what i want to do is. I want to move only recordings of voice memos in iphone to another folder.

The voice recording's EXIF looks like this (attachment). So if i want to select all these files and move to another folder, how would the cording go?

Phil Harvey

#7
The command you were running was this:

exiftool "-FileName<MediaCreateDate" -ext jpeg -d "%Y%m%d_%H%M%S.%%e" "F:\June 14 Backup\Pictures/*"

Which renames only files with extension "jpeg".  If you want to rename the mp4 files, change "jpeg" to "mp4" in the command.  The screenshot you posted of the -time:all tags in your mp4 file does contain MediaCreateDate, so this should work with -ext mp4.  You can add multiple -ext options for all the files you want to rename, but the jpeg files won't contain MediaCreateDate, so your command would have to look something like this:

exiftool "-FileName<MediaCreateDate" "-filename<createdate" -ext jpeg -ext jpg -ext mp4 -d "%Y%m%d_%H%M%S.%%e" -r "F:\June 14 Backup"

Here I have added -r to recurse into all "June 14 Backup" subdirectories.

Now your second question:  To move all your voice memos to another folder you need to find some tag that is unique to these files.  Perhaps the iTunSMPB tag.  Then the command would be like this:

exiftool "-directory=F:\some other directory\" -if "$iTunSMPB" -r "F:\June 14 Backup"

- Phil

Edit: I fixed a mistake in my last command.  It should be -directory= (not -directory<) because it is a simple assignment.
...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 ($).

bilalalthaf

WOW SIR YOU ARE GREAT. HATS OFF.

THE CODING OF THIS EXIFTOOL APP MAY LOOK SIMPLE. BUT I CAN IMAGINE HOW MUCH OF EFFORT WOULDVE BEEN PUT TO MAKE IT :/

bilalalthaf

im getting this error when im trying to move the voice memos to another foldder :(

Phil Harvey

Yes, sorry.  I corrected my mistake in the command in my last post.

Although there may be a another problem because it seems that all but one of the files failed the condition.

- 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 ($).

bilalalthaf

ok thank you so much for such a quick reply :)

bilalalthaf


Hayo Baan

What was the exact command you used? I'm sure there is a typo somewhere.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Also, it would be great if you could copy and paste the commands as text instead of doing the screen captures because the screen captures waste bandwidth and forum storage space, and I can't download them over dialup (which I am on right now).

- 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 ($).