Adding IPTC tags to directory of jpgs using exiftool -json="info.json" "dir"

Started by Skippy, August 11, 2015, 05:03:48 AM

Previous topic - Next topic

Skippy

When I run the following command line,
F:\Skippy\Development\PhotoHarvester\Access\exiftool.exe  -json="F:\Skippy\Development\PhotoHarvester\Access\TmpPhotoID.json" "E:\DCIM\141_0604\"

I find that none of the jpgs have been modified and that exiftool returns the following message.
1 directories scanned
0 image files read


The json file validates and the first few lines look like:
[
  {
  "SourceFile":"IMG_1540.JPG",
  "Instructions": "{7C704161-A4DC-4EA1-B850-C81687E0DB04}|DCIM/141_0604/|IMG_1540.JPG|6/04/2015",
  "City": "Cairns"
},
{
  "SourceFile":"IMG_1541.JPG",
  "Instructions": "{7C704161-A4DC-4EA1-B850-C81687E0DB04}|DCIM/141_0604/|IMG_1541.JPG|6/04/2015",
  "City": "Cairns"
}
]


I have built a GUID for the photos using the GUID from the card they were first stored on and the directory, file name and photo date.  I am trying to write this GUID back to the photos on the SD Card, before I import the photos onto my hard drive.  I have no idea why the process fails.  The json file is generated by ms-access and I have set the ASCII switch to force encoding in ascii. 

The intended destination for the tags is the IPTC fields.

I have been generating the shell command in ms-access but pasting it into the cmd window for debugging. I have no idea of what to try next.

Skippy.


Phil Harvey

Hi Skippy,

Quote from: Skippy on August 11, 2015, 05:03:48 AM
When I run the following command line,
F:\Skippy\Development\PhotoHarvester\Access\exiftool.exe  -json="F:\Skippy\Development\PhotoHarvester\Access\TmpPhotoID.json" "E:\DCIM\141_0604\"

I find that none of the jpgs have been modified and that exiftool returns the following message.
1 directories scanned
0 image files read

I would think this means there are no images in E:\DCIM\141_0604\.  But even if there are it won't work because your SourceFile doesn't specify the same path as you used on the command line.

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

Skippy

Thanks Phil for your suggestions

I have done some more tests since and found the main problem, which was a trailing back slash in the target directory.  If the backslash is removed from E:\DCIM\141_0604\, data does get written to jpeg files on the SD card.






Phil Harvey

Thanks for this report.  I'll have to look into this because it should work with the trailing backslash.

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

Phil Harvey

I've finally dragged out the PC to look into this.  This command works with a trailing backslash in Windows XP:

exiftool -json=a.jpg e:\tmp\

So there must be something else going on here.

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

Skippy

I know it can take a huge amount of time to track down the source of even simple issues and I appreciate your looking into this.  I have just re-tested things at my end and the result is the same, the trailing backslash in the search directory must be removed.  A screen clip is provided showing the results of the command line with and without a backslash in the search directory.  Previously I had been writing to jpegs on a SD card and this test was directed to jpegs on a local hard drive folder, but the results were the same.

From what I understand of windows, the cmd line interface is being rolled into Powershell in future versions of windows.  This may create subtle issues.  Another potentially related issue is the need to use quotes in the cmd string.  I am finding quoting everything is essential.

Can someone also please tell me how to insert images into this forum too, assuming I want to upload an image for display.

Phil Harvey

Could you tell me what version of ExifTool you are using?  And what version of Windows?

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

StarGeek

I just noticed that you're using a different shell (tabbed, has a search, plus lots of info at the bottom).  Have you tried your command in a regular CMD or PowerShell?

And may I ask what shell that might be?  I'm always on the lookout for something better.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Skippy

@ StarGeek
In Windows 8.1 (Home) 64 bit with all updates, using Powershell works with or without a backslash in the jpeg folder. 
F:\Skippy\Development\PhotoHarvester\Access\exiftool.exe  -json="F:\Skippy\Development\PhotoHarvester\Access\TmpPhotoID.json" "E:\DCIM\141_0604\ works so does
F:\Skippy\Development\PhotoHarvester\Access\exiftool.exe  -json="F:\Skippy\Development\PhotoHarvester\Access\TmpPhotoID.json" "E:\DCIM\141_0604.

Using the plain old CMD prompt, only the cmd *without* the backslash works.

I am using Conemu which has been recommended in some open source forums.  Editing the cmd line is really painful.  In Win 8.1 if you go into the properties of the cmd window, there is a quickedits option that makes it easier to edit cmds but it only improves matters a bit.  I also tried powercmd, a commercial utility and it looks good but if I run exiftool without arguments to see the information, I can't advance through the pages of help using spacebar, so I had to drop this one.  There is also Windows Powershell ISE which is part of windows but which is hidden by default and needs to be turned on before it can be used.  Windows Powershell ISE is an IDE for cmds and it works with the test exiftool cmd in both 64 bit mode and 32 bit mode.  It also has syntax colouring and elimates the skinny window nonsense of ordinary command windows.  However it can produce verbose error messages that are a bit hard to understand and in a colour combination red on deep blue that is hard to read.  Conemu seems to be the easiest cmd line improvement.

Skippy

I have reached the point that I need to get to (until I have another issue).  Final question for today.  If I am using Json to instruct exiftool how to process each jpg, can feedback from exiftool be put into a log file.  If exiftool is called by an application, then there will be no window to report error messages.  I don't need any exif data in the log.  I am hoping for a log that lists events such as whether each jpg was read or written to.

Just wondering aloud, if someone uses a device or file format or version of operating system that exiftool does not know well, there could be issues.  When releasing an application that depends on exiftool into the wild, there has to be someway of finding out about these issues and reporting them, so I think that a log file is very important.  My tools are database driven and tend to affect tens to hundreds of files in each invocation of exiftool.  There is also no photo-based user interface as there is with photo managers, so there is no instant feedback if something were to go wrong.  The only workaround that I can think of a the moment is to pick up something that Phil mentioned before and that is to copy the backups to a directory on a hard drive, when info is written to originals on SD Cards.  I have to admit I can't figure out where to add the arguments after half an hour of reading and head scratching that will cause backup jpgs to be written to a different directory.  What would I need to add to this cmd to get backups routed to C:\temp\?

F:\Skippy\Development\PhotoHarvester\Access\exiftool.exe  -json="F:\Skippy\Development\PhotoHarvester\Access\TmpPhotoID.json" "E:\DCIM\141_0604




StarGeek

Quote from: Skippy on August 19, 2015, 06:54:49 PM
Using the plain old CMD prompt, only the cmd *without* the backslash works.

Ok, got it.  Basic CMD is interpreting the backslash as an escape for the double quote.  It becomes obvious if you have something beyond the directory path.  You could switch the backslashes to slashes and it will make no difference to ExifTool and work properly in CMD, though, depending upon what other programs you use, might cause problems elsewhere in the workflow.

C:\Windows\System32>exiftool -keywords "X:\!temp\z\"
    1 directories scanned
    0 image files read

C:\Windows\System32>exiftool -keywords "X:\!temp\z\\"
======== X:/!temp/z/Test01.Jpg
Keywords                        : Ani-Mia, Comic Con 2013 Day 1, Gender Bent Costume, Great Saiyaman II Costume, Thor Costume, Toni Darling
======== X:/!temp/z/Test02.Jpg
Keywords                        : Ani-Mia, Comic Con 2013 Day 1, Gender Bent Costume, Great Saiyaman II Costume, Thor Costume, Toni Darling
    1 directories scanned
    2 image files read

C:\Windows\System32>exiftool "X:\!temp\z\" -keywords
File not found: X:/!temp/z" -keywords


QuoteI also tried powercmd, a commercial utility and it looks good but if I run exiftool without arguments to see the information, I can't advance through the pages of help using spacebar, so I had to drop this one.

This is the shell I use and it worked great in XP but has serious problems popped up under Windows 8 & 8.1. Reading input from STDIN doesn't work and redirection will mirror the entire output to STDOUT.  So I'm glad to hear that it's not just some stupid setting on my end.  Still, these are things I'm willing to work around for tab completion and proper and sane copy/paste.  Still searching for a better Windows shell.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Skippy

Thanks StarGeek.

I also need to remove a dumb request that I made in my last post.  If I want to back up files from SD Cards before writing to the originals, I will get my application to do this rather than requesting Exiftool to do it.  That way I will have far more control. 

I am still wondering if exiftool makes a log file though.  I get the impression that it can for operations on a single file (">log.txt") but may not do so for an invocation that processes an entire folder.

StarGeek

Quote from: Skippy on August 20, 2015, 06:50:45 PM
I am still wondering if exiftool makes a log file though.  I get the impression that it can for operations on a single file (">log.txt") but may not do so for an invocation that processes an entire folder.

I think it's the -v option. 
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

You can always redirect the exiftool console output to file.  It doesn't matter if you are processing a file or a directory.

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