ExifTool Forum

ExifTool => Newbies => Topic started by: bilalalthaf on June 19, 2014, 05:34:12 PM

Title: add extension to extension-less files.
Post by: bilalalthaf on June 19, 2014, 05:34:12 PM
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
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 19, 2014, 08:01:55 PM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 20, 2014, 05:44:11 AM
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?
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 20, 2014, 05:45:27 AM
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
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 20, 2014, 07:37:13 AM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 22, 2014, 01:27:28 PM
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.
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 22, 2014, 01:51:51 PM
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?
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 23, 2014, 07:28:19 AM
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.
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 23, 2014, 01:03:40 PM
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 :/
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 23, 2014, 01:32:48 PM
im getting this error when im trying to move the voice memos to another foldder :(
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 23, 2014, 01:49:34 PM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 23, 2014, 01:59:12 PM
ok thank you so much for such a quick reply :)
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 23, 2014, 02:02:25 PM
still no luck, plz help :(
Title: Re: add extension to extension-less files.
Post by: Hayo Baan on June 23, 2014, 03:47:30 PM
What was the exact command you used? I'm sure there is a typo somewhere.
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 23, 2014, 07:36:34 PM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:05:31 PM
Ok it was my mistake. I'm Done :D
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:11:02 PM
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
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 24, 2014, 01:17:02 PM
The number of -if commands is infinite.  See the application documentation (https://exiftool.org/exiftool_pod.html#if_expr) for a description of the syntax.

- Phil
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:24:11 PM
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?
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 24, 2014, 01:25:30 PM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:27:51 PM
Thanks Boss :)  :D
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:34:13 PM
When i used the "if duration" tag only the m4a files got moved. the mp3 and wav format files werent moved :/
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:37:07 PM
plz help
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 24, 2014, 01:39:17 PM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:44:35 PM
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?
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 24, 2014, 01:46:01 PM
Did you forget the "#" after "duration" in your commands?

- Phil
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 01:50:24 PM
no i did not forget becoz i copied exactly what you quoted
Title: Re: add extension to extension-less files.
Post by: Phil Harvey on June 24, 2014, 01:55:18 PM
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
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 02:16:54 PM
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..
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 02:18:51 PM
ok sir. i finally got something done by myself :P

i added the tag -ext mp3 wav.. and it did the job :)
Title: Re: add extension to extension-less files.
Post by: bilalalthaf on June 24, 2014, 02:42:56 PM
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 :)
Title: Re: add extension to extension-less files.
Post by: orax on June 24, 2014, 03:47:49 PM
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 =