Strugging with Exiftool

Started by vetinry, May 31, 2014, 08:20:26 AM

Previous topic - Next topic

vetinry

Hello all

I'm trying to rename some pictures with Exiftool from the command line and ideally using a batch file because I will want to run this several times for approx 15000 photos.

I've downloaded Exiftool.exe-k, renamed to just exiftool and moved to my windows folder.

Using Windows 7, I've opened the cmd box and the default there is c:\Users\Steve>, so not sure if this now means that my .exe is in the right place.  I have tried with exiftool in the path that the command line is pointing to.

In order to test I have, on the desktop, set up a "Test" folder where I want the picture to go, and a "Pic" folder, where I have put a few photos to practice.

I have then entered the following into Notepad on 3 lines as per below and saved as a .bat file on the desktop

exiftool-d %%Y%%m%%d-%%H%%M%%S%%%%-c.%%%%e
-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}
c:\Users\Steve\Desktop\Pic

I got this from a blog on life hacker where I originally got inspired to do this project.

I also tried putting the full path of exiftool in the file but then it seems to open up the help pages within exiftool without completing any renaming

When I double click on the batch file, the black CMD box appears for a split second (not long enough to read) and then disappears.  And nothing has happened to the files.

I'm sure that I am doing something obvious and stupid but can't work out what.

Please can someone help

Many thanks

Steve




ryerman

Quote from: vetinry on May 31, 2014, 08:20:26 AM
I've downloaded Exiftool.exe-k, renamed to just exiftool and moved to my windows folder.

Using Windows 7, I've opened the cmd box and the default there is c:\Users\Steve>, so not sure if this now means that my .exe is in the right place.  I have tried with exiftool in the path that the command line is pointing to.
Because exiftool.exe is in your Windows folder, you can now execute exiftool from any directory without using its full path.  It won't matter which directory is in the command prompt.

Quote from: vetinry on May 31, 2014, 08:20:26 AM
I have then entered the following into Notepad on 3 lines as per below and saved as a .bat file on the desktop

exiftool-d %%Y%%m%%d-%%H%%M%%S%%%%-c.%%%%e
-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}
c:\Users\Steve\Desktop\Pic
For any command line:
There must be a space after exiftool
Quotes are needed for options that use "special" characters (like "<") and paths that contain spaces. I always quote all paths.

In a BAT file:
The command must be on one line.
% used in the exiftool options must be doubled. So your -dateFormat (-d) is correct for a BAT file but it should be -d %Y%m%d-%H%M%S%%-c.%%e in a command window.

Quote from: vetinry on May 31, 2014, 08:20:26 AM
When I double click on the batch file, the black CMD box appears for a split second (not long enough to read) and then disappears.  And nothing has happened to the files.
The -k option will keep the command window open after execution.

Try this:
exiftool -k -d %%Y%%m%%d-%%H%%M%%S%%%%-c.%%%%e "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" "c:\Users\Steve\Desktop\Pic"

If you use this:
exiftool -k -d %%Y%%m%%d-%%H%%M%%S%%%%-c.%%%%e "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" %1
you can drag and drop any file or folder onto the BAT file and avoid editing it for every new folder.

Note that %1 is a batch file parameter and is not part of exiftool and so the % is not doubled.
You can learn more about batch file parameters here: http://pages.citebite.com/v3s3y1x0p0fhq

Jim
Windows 10 Home 64 bit, Exiftool v12.61

vetinry

Hey Jim

Thank you very much for your reply.  I've tried both of those and they work brilliantly.  Really wish I'd been able to work it out for myself but guess this is still a bit beyond me

I'm just wondering now how much I can tweak the date and time format.  I have managed to insert underscores between the Year, Month and Day, which, for me anyway, looks easier to read.

I also tried to split the time using a colon (:), but it doesn't seem to like that.  It does however allow dots. 

exiftool -k -d %%Y_%%m_%%d-%%H.%%M.%%S%%%%-c.%%%%e "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" "c:\Users\Steve\Desktop\Pic"

Please can I ask a few more questions?
Is it possible to have a space in the filename, or do all the characters need to join?
Why is it not possible to use a colon for the time?
If I wanted to have a bracket around the multiple file numbers, where do you put the brackets?

Best wishes

Steve

vetinry

Hi Jim
I love the option to drag the folders directly onto the batch file.  That's hopefully going to make things much easier than keep changing the file.

I've run into another hurdle though.  I've just tried dragging an assortment of pictures into the batch file.  Of about 500 files, 250 were changed, about 100 were movies (from iphone - do these have any tags?) and a further 150, which don't appear to have a date taken for them.

Can you change the {original date taken} to something else.  There does appear to be a date modified tag, although this is only from windows explorer.  I haven't yet looked at the files themselves

Cheers

Steve

Phil Harvey

Hi Steve,

Colons are illegal in Windows file names, but you can add spaces if you have quotes around the argument.  Reading the documentation on writing the filename and directory tags may help with the date/time formatting.

I'm not sure what you mean about brackets around the file number.

You can add as many arguments as you want to write Filename from various other tags.  The last one on the command line with a tag that exists will take precedence.  Since all files have a system FileModifyDate, you can add this first to use it as a default if the other tags don't exist (DateTimeOriginal in this case).

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

vetinry

Many thanks Phil

Am making some progress.

At first, I thought I could simply add "FileModifyDate" to the existing string:

exiftool -k -d "%%Y_%%m_%%d %%H.%%M.%%S%%%%-c.%%%%e" "-filename<c:\Users\Steve\Desktop\Test\${FileModifyDate}\${DateTimeOriginal}" %1

but I soon realised that I needed to add a seperate argument

exiftool -k -d "%%Y_%%m_%%d %%H.%%M.%%S%%%%-c.%%%%e" "-filename<c:\Users\Steve\Desktop\Test\${FileModifyDate}" "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" %1

This now seems to work ok

The brackets piece was to see whether I could get a "(" and ")" around the -c part if there were multiple file numbers.  I know that using seconds makes this unlikely, but I might only use hours and minutes.  Plus it also looks better.

So, currently 2 files report:

YYYY_MM_DD HH.MM.SS-1
YYYY_MM_DD HH.MM.SS-2

and ideally I'd like it to look like:

YYYY_MM_DD HH.MM.SS (1)
YYYY_MM_DD HH.MM.SS (2)

I've tried adding in brackets to the argument but whilst it works if there are multiple file numbers,  it unfortunately returns:

YYYY_MM_DD HH.MM.SS() for every normal file

Is there a way to do this?  It's certainly not a massive problem if not, but I'm just trying to see what's possible before I start on the project

Cheers

Steve

Phil Harvey

Hi Steve,

Your command looks good.

About the brackets:  Thanks, I see now.  This is what the %-c does for the dash, but unfortunately there is no way to do this with brackets.  But you could go around afterwards and do this:

exiftool "-filename<${filename;s/-(\d+)$/ \($1\)/}" 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 ($).

vetinry

Hi Phil
Thanks again for the reply.
I've tried creating a batch file with the script you provided but it doesn't seem to be doing anything.
Is this a drag and drop batch or am I supposed to be added the file / folder information?

Best wishes

Steve

Phil Harvey

Hi Steve,

In a BAT file, that last command would look like this:

exiftool "-filename<${filename;s/-(\d+)$/ \($1\)/}" %*

(here, I use "%*" instead of "%1" so you can drop more than 1 file and/or folder at the same time)

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

vetinry

Evening everyone

Quick update

Project going really well.

I sorted out all of the duplicates and am now in the process of renaming all of the files using the batch file further up this post.

At the minute, I am only sorting and filing in years, but for 2013 for example, I have over 2000 photos.  Therefore I'd like to split by month and wondered if there was a neat way of doing this with Exiftool?

The manual way will be to create 12 "month" folders within each year and then sort the pictures and cut and paste into each folder.  But I'd love to get even more use out of this great tool if possible.

The next thing I'm grappling with is uploading iphone photos from my wife's phone.  She tends to keep lots of older photos on her phone. Previously I was importing using picasa, which was able to ignore the duplicates which had already been uploaded.  I'm not sure if this will still work because of renaming files.  Therefore I want to try and find a neat way of being able to back up her pictures and rename them into the project without creating lots of duplicates.  Any thoughts?

CHeers

Steve

Phil Harvey

Hi Steve,

Creating month folders is easy.  See example 6 on the "Writing FileName and Directory tags" page for an example of creating a year/month/day directory structure.

I can't help much about the duplicates.  You need some other technique to remove these.

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

vetinry

Project Update

Good evening all.  Well, it's been a little while since I've posted here.  I've been making slow progress with the project, amidst many of life's other priorities.

Thus far, I've managed to remove most of the duplicates and all of the files are renamed using the batch file that Jim and Phil helped with. Absolutely awesome piece of software!

Now I have 2 further challenges....

1.  Organising the files into month sub folders, ideally using "January 2014, February 2104 etc rather than 01-2014)  I had some challenges with not all of my file having Date Created tags and so my file naming used this as the default and then file modify date as the secondary.  Is there now a way to use the file name to do the organising, or do I need to continue to use these tags as the basis?  I'd like to use a batch file to organise the files and think that a seperate process might be desirable because I also need to sort out duplicates before I file.
2. Duplicates.  After spending so long trying to get my arms around thousands of pictures, I really want to find a simple process to keep things organised.  The main challenge I have is that my wife doesn't like to delete all of the photos from her iphone and therefore I can't find an automated way of uploading her photos. What I do now is copy all of the pictures to a desktop folder, create new file names and then search for duplicates against my main picture folder. Once I've removed the duplicates, I then copy the new pictures over.....
....any ideas to make this more simple.

Really hope someone can help, at least with point 1

Many thanks

Steve

Phil Harvey

You can write to directories like "January 2014" by changing your command from this:

exiftool -k -d "%%Y_%%m_%%d %%H.%%M.%%S%%%%-c.%%%%e" "-filename<c:\Users\Steve\Desktop\Test\${FileModifyDate}" "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" %1

to this

exiftool -k -d "%%B/%%Y/%%Y_%%m_%%d %%H.%%M.%%S%%%%-c.%%%%e" "-filename<c:\Users\Steve\Desktop\Test\${FileModifyDate}" "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" %1

The duplicates thing is a problem, but all you have to do is check the files that end up with a copy number in their name.  I imagine that it wouldn't be too difficult to write a script or .bat file to compare the md5 for these files and delete any duplicates.

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

vetinry

I've tried the new command line in a batch file.  The month and year were wrong way round, which was fine.

But.... I've tried to run some already processed pictures back through the batch file and unfortunately it appears to have overwritten loads of them with yesterday's date - the date I copied them back from the NAS to my desktop for processing.

If I click on a file property in Explorer, it's showing the file create and file modify date as 23/11/2014.

Some of the affected files are from the birth day of my son so I know for sure that they're wrong.  Has the Exif data corrupted, or will the date time original still be present?

Really hope I've not messed this up

Hope someone can help

Best wishes

Steve

Hayo Baan

What does exiftool -datetimeoriginal FILE tell you for one of those files?

The command Phil showed you sure did not change the metadata, so it should still be there, or it wasn't there in the first place (or perhaps simply not in the datetimeoriginal tag).

Hope this helps,
Hayo
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

Hi Steve,

Odd.  Just changing the FileName should not affect the file creation/modification dates.  But if you changed something else unintentionally with ExifTool, then you will find the "_original" files that ExifTool creates to allow the original files to be restored.

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

vetinry

It's official....

I am an idiot.  Upon further checking, I found that all of the (what I thought was corrupted files) were in my November file, consistent with the date that I was using the new batch file.  I checked the EXIF data for them and found that they didn't have any Date Time Original info.  Strange, I thought.  I just thought that I'd count how many files there were in case that I needed to rename them all.  754 files.  Thankfully my short term memory kicked in and I remembered that I'd converted exactly 754 RAW images to JPEG the previous day.

Do RAW files not carry EXIF info?  Or did I remove this during my conversion.  I just used a freeware program to convert from RAW to JPEG (could this have been done with Exif Tool?).

So, at least I know where these files came from. Next couple of questions.  Can Exif Tool rename RAW files?  Unfortunately, these 754 files now seem to have 23/11/2014 as their date created and date modified dates and no other information.

And does anyone know if there is a good programme for comparing pictures that are identical in image but different in size.  I use Fast Duplicate Files to look for exact copies, but I would like to check whether these RAW (now JPEG) images are duplicates of other files.  I can only think at one point I was shooting in RAW, but I'm sure that I would only have done that if I was also shooting a JPEG at the same time.

Anyway, thanks for the responses as always.  Very reassuring to know that I couldn't have altered the Exif information using the batch commands.

Best wishes

Steve

Phil Harvey

Hi Steve,

Quote from: vetinry on November 25, 2014, 03:24:42 PM
It's official....

I am an idiot.

I doubt that very much. :)

QuoteDo RAW files not carry EXIF info?

Often not.  Many people use ExifTool to copy the metadata from RAW to JPG images.

QuoteI just used a freeware program to convert from RAW to JPEG (could this have been done with Exif Tool?).

ExifTool does not develop RAW images.  The best you can do is use ExifTool to extract any embedded JPEG from the RAW.

QuoteCan Exif Tool rename RAW files?

ExifTool can rename any file.  (It doesn't even need to be a supported format.)

QuoteUnfortunately, these 754 files now seem to have 23/11/2014 as their date created and date modified dates and no other information.

If you want, you can rename the files from the metadata in the corresponding RAW file. This is easy if they have the same name.  For example, if the RAW files have ".nef" extension:

exiftool -tagsfromfile RAWDIR/%f.nef "-filename<..." ...

QuoteAnd does anyone know if there is a good programme for comparing pictures that are identical in image but different in size.

Sorry, I can't help with this.

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

vetinry

Is it really over 5 years since my last post?

Good evening everyone.  I am writing from a new and very different life than I had before.  But strangely still with some of the same challenges.
I'm trying to resurrect my photo filing to deal with a mountain of new photos from me and from a new relationship.
I've dug out all of the old work, downloaded latest exiftool, moved to windows and removed the "k"
On my desktop I have set up another Test folder and also copied one of the strings above into notepad and saved as a batch file.
However, as soon as I drag a photo onto the batch file, the command prompt opens and seems to be constant scrolling down through the same repeating line, without ending and without renaming the photo.
Any idea what I'm doing wrong?
Using Windows 10 rather than 7 and a faster laptop but nothing else changed so can't understand what's happening
Thanks in advance

Steve

StarGeek

It would help to know what exactly you put in the bat file and if possible, what the repeating line is.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

vetinry

Hi StarGeek

Oops - yes, that would have been helpful....

This is the line in the bat file:

exiftool -k -d "%%Y_%%m_%%d %%H.%%M.%%S%%%%-c.%%%%e" "-filename<c:\Users\Steve\Desktop\Test\${FileModifyDate}" "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" %1

This is a straight copy of what I used previously and so I assumed it would be right (never assume anything).  I know that I spent quite a bit of time getting to begin to understand this last time and just about got the hang of it.  But I've pretty much forgotten it all and so just hoping there is a simple fix which means that I don't have to do that.

I've taken a screenshot - is there a way to upload a picture here?

The line says:

c:\Users\Steve\Desktop>exiftool -k -d "%%Y_%%m_%%d %%H.%%M.%%S%%%%-c.%%%%e" "-filename<c:\Users\Steve\Desktop\Test\${FileModifyDate}" "-filename<c:\Users\Steve\Desktop\Test\${DateTimeOriginal}" -k

It seems to just continue to repeat this and scroll quickly down without stopping

Any ideas?

Thanks

Steve


StarGeek

To attach a file to the post, click the "Attachments and other options" just below the text box.

I don't see anything wrong with the command and it seems to work here.  Rather than drag/dropping a file on it, try running it from CMD.

What is the name of the file you are trying to process?
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

vetinry

Thank you for trying to help

Name of file: IMG_1917

How do I run from CMD?  The reason I liked the .bat is that I could throw an entire folder on to the .bat sitting on the desktop and it would then process everything and pop the renamed files in my Test folder.

I've attached the picture so you can see what opens when I drop the photo onto the bat file.

So frustrating - it used to work perfectly.  And I know that I'm not skilled enough to diagnose on my own

Best wishes

Steve


Phil Harvey

Somehow it looks like your .bat file is in an endless loop.  If you attach the entire .bat file we can see what the problem is.

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

vetinry

Hi Phil

Hope you're well.  Yes, that's exactly what's happening - I just wasn't able to describe it properly

Here is the file...

Thanks

Steve

Phil Harvey

The problem is that your .bat file is calling itself.  The first command in the .bat file is "exiftool", which is the name of the .bat file, so it runs itself... endlessly.

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

vetinry

Hi Phil

I thought I'd called it that same name previously but obviously not.  Batch file renamed to "Exiftoolbatch" and now it works perfectly

Thank you very much for working out what was wrong

Best wishes

Steve