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

bilalalthaf


bilalalthaf

Please list me all the IF commands. Or give me a link to the forum where all the If Commands are there. With the if command you gave me i did 70% of my sorting work. Thanks so much :D

Phil Harvey

The number of -if commands is infinite.  See the application documentation for a description of the syntax.

- 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

im not so advanced to understand all that. let me make it simple :(

1) if i want to move audio files more than 55 seconds to another folder. what would be the if function i should use?

2) if i want to move picture files bigger than the size 500x500. what should be the if function i should use?

Phil Harvey

Quote from: bilalalthaf on June 24, 2014, 01:24:11 PM
1) if i want to move audio files more than 55 seconds to another folder. what would be the if function i should use?

-if "$duration# > 55"

Quote2) if i want to move picture files bigger than the size 500x500. what should be the if function i should use?

-if "$imagewidth > 500 or $imageheight > 500"

(use "and" instead of "or" if you want both width and height to be greater)

- 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

When i used the "if duration" tag only the m4a files got moved. the mp3 and wav format files werent moved :/


Phil Harvey

What is the output of this command for these files?:

exiftool -duration# FILE

You may use any available tag name in the expression.  Extract all tags with exiftool -s to see what is available.  If Duration isn't available, maybe using FileSize instead would be possible.

- 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

actually i found the problem out but i dont know to solve. you would know. the issue is that all those files have the duration, but
after the duration they have the tag called <approx>

example

Duration : 00:02:45 <approx>

so whats the solution?

Phil Harvey

Did you forget the "#" after "duration" in your commands?

- 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

no i did not forget becoz i copied exactly what you quoted

Phil Harvey

Then you must be using a very old version of ExifTool.  Try upgrading to a more recent version.  The current version is 9.65.

- 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

I'm already using the latest version. And i repeat. Its only moving (.m4a) files. Not the wav mp3 and ogg files. As i said its showing <approx> after the file.

and the file size wont be fine. bcoz wav files are bigger in size. and if i wanted to do by size. i could do it directly by sorting the files by size on windows explorer itself..

bilalalthaf

ok sir. i finally got something done by myself :P

i added the tag -ext mp3 wav.. and it did the job :)

bilalalthaf

im trying to assort only my screenshots. so i used your method and mentioned the image height and width according and also specified the file type to png.. used both the following codes.

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
C:\Users\Abdur Rahim>exiftool "-directory=F:\Sorted June 14 Backup\Sorted\Sorted
all Screenshot" -if "$imagewidth = "640" or $imageheight = "1136"" -ext png -r
"F:\June 14 Backup\Pictures"
    3 directories scanned
2025 image files updated
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
when i do the above, it moves all the png files..


"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
C:\Users\Abdur Rahim>exiftool "-directory=F:\Sorted June 14 Backup\Sorted\Sorted
all Screenshot" -if "$imagewidth > 640 or $imageheight > 1136" -ext png -r "F:\
June 14 Backup\Pictures"
    3 directories scanned
1996 files failed condition
   29 image files updated
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
when i did the above. it is moving the png images of the width 640 or more. and height of 1136 and more. i want the pngs of ONLY 640x1136 to be moved.. hope my explanation was enough.

plz gimme the coding :)

orax

#31
Try with "and":
exiftool "-directory=F:\Sorted June 14 Backup\Sorted\Sorted all Screenshot" -if "$imagewidth == 640 and $imageheight == 1136" -ext png -r "F:\June 14 Backup\Pictures"

Edit: it's == instead of =