ExifTool Forum

ExifTool => Bug Reports / Feature Requests => Topic started by: mazeckenrode on June 17, 2025, 10:55:03 AM

Title: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: mazeckenrode on June 17, 2025, 10:55:03 AM
I encounter the 'No sourcefile in imported JSON database' error from time to time, and most of the time the problem is attributable to a mismatch between the filename provided on the command line to operate on and the one embedded as sourcefile in the JSON to be imported, or trying to operate on a file with too long a pathname, but once in a while the actual problem is demonstrably NOT due to any of those situations. For instance, I just tried to import from a JSON to a PDF, but I had inadvertently mangled the format of one tag's data to be imported. ExifTool reported:

Format error in JSON file 'JSON file'
No SourceFile 'T:/Temp/Test.pdf' in imported JSON database

If it matters, the tag data that I had mangled was for XMP:Keywords, which I had formatted as ""keyword1","keyword2","keyword3"", and I assume that "Format error in JSON file" was in reference to that mistake on my part. Once I replaced all instances of "","" with "; ", it imported with no further errors. But the sourcefile name matched the filename provided on the command line all along. Is it supposed to work like that? I think it's unnecessarily confusing. It would also be nice if "Format error in JSON file" could be made to be more specific. Maybe at least have it indicate which tag(s) data are formatted incorrectly?
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: StarGeek on June 17, 2025, 10:57:05 AM
We can't troubleshoot it without an example JSON file that shows the problem.
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: mazeckenrode on June 17, 2025, 11:59:09 AM
Attached: "2025-06-17 09;49;56 - MAZE - Test.7z" (1,614)

Contents:

"2025-06-17 09;49;56 - MAZE - Test\"
  "2025-06-17 09;49;56 - MAZE - Test.pdf" (3,875) [1 p, 0 w, 0/0 ch, 0 l]
  "2025-06-17 09;49;56 - MAZE - Test [1 (incorrect)].pdf.json" (523)
  "2025-06-17 09;49;56 - MAZE - Test [2 (corrected)].pdf.json" (521)

2025-06-17 09;49;56 - MAZE - Test.7z
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: StarGeek on June 17, 2025, 12:50:02 PM
What is the current directory you are running the command from? Is the PDF in the current directory.

The "Sourcefile" must include either the relative path to the current directory or the absolute path to the file. If there is no path in the file, then exiftool looks for the file in the current directory.

If you run the command with -v2 (-verbose2) option (https://exiftool.org/exiftool_pod.html#v-NUM--verbose), then the output will display the path that exiftool is using to look for the file.

For example, here exiftool shows (full path: 'C:/2025-06-17 09;49;56 - MAZE - Test.pdf')
C:\>exiftool -P -overwrite_original -j="Y:\!temp\x\y\z\2025-06-17 09;49;56 - MAZE - Test\2025-06-17 09;49;56 - MAZE - Test [2 (corrected)].pdf.json" "Y:\!temp\x\y\z\2025-06-17 09;49;56 - MAZE - Test\2025-06-17 09;49;56 - MAZE - Test.pdf" -v2
Reading JSON file Y:\!temp\x\y\z\2025-06-17 09;49;56 - MAZE - Test\2025-06-17 09;49;56 - MAZE - Test [2 (corrected)].pdf.json
Imported entry for '2025-06-17 09;49;56 - MAZE - Test.pdf' (full path: 'C:/2025-06-17 09;49;56 - MAZE - Test.pdf')
======== Y:/!temp/x/y/z/2025-06-17 09;49;56 - MAZE - Test/2025-06-17 09;49;56 - MAZE - Test.pdf
No SourceFile 'Y:/!temp/x/y/z/2025-06-17 09;49;56 - MAZE - Test/2025-06-17 09;49;56 - MAZE - Test.pdf' in imported JSON database
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: mazeckenrode on June 17, 2025, 01:34:45 PM
Quote from: StarGeek on June 17, 2025, 12:50:02 PMWhat is the current directory you are running the command from? Is the PDF in the current directory.

Current directory/fullpath on my machine was T:\Temp\2025-06-17 09;49;56 - MAZE - Test\2025-06-17 09;49;56 - MAZE - Test.pdf. As you may recall from my numerous previous topics and posts, I have almost all ExifTool ops configured as custom commands via Directory Opus, which feeds it current directory/fullpath/filename as necessary.
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: StarGeek on June 17, 2025, 02:24:13 PM
You're passing the full path to the PDF, but it doesn't seem like that is the directory that DOpus is executing exiftool from.

For the JSON to work with a "Sourcefile" value that doesn't include the path, DOpus would need to CD to T:\Temp\2025-06-17 09;49;56 - MAZE - Test\ before running the exiftool command.

See if you can capture the STDOUT, add the -v2 option, and check to see what the "full path:" that exiftool is using. See this DOpus post (https://resource.dopus.com/t/scripting-getting-external-program-output/20066/2), though it may be outdated as it is 10 years old.
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: mazeckenrode on June 17, 2025, 06:00:20 PM
Quote from: StarGeek on June 17, 2025, 02:24:13 PMYou're passing the full path to the PDF, but it doesn't seem like that is the directory that DOpus is executing exiftool from.

But it IS the same directory. Can you please explain why "it doesn't seem like that is the directory that DOpus is executing exiftool from"? DOpus opens a command prompt window for output — I should probably specify that I'm using the latest Windows x64 exe version of ExifTool under Windows 10 x64 if anyone hasn't already guessed — and the final command prompt following the command is that same directory (T:\Temp\2025-06-17 09;49;56 - MAZE - Test>). In DOpus, under normal circumstances (which in general are MY circumstances), the active/current directory for any command is the one being displayed in the active window's SOURCE lister, and the directory shown above is the one I'm in when operating on the PDF in question. But, in the interest of full disclosure and cooperation...

My ExifTool command as normally issued via DOpus is:

exiftool -config MAZE_PDF+XMP_Custom.config -m "-json={filepath$}.json" "{filepath$}"

({filepath$} being DOpus' method of passing the full path and filename. I could actually just use {file$} for most of my metadata import operations, since I'm already in the directory containing the file, but I have occasional special circumstances, not relevant to this particular import operation, which require me to pass the full path.)

At your request, I've now added -v2 to my custom command, which output the following (used with "2025-06-17 09;49;56 - MAZE - Test [2 (corrected)].pdf.json" renamed as "2025-06-17 09;49;56 - MAZE - Test.pdf.json"):

Writing PDF:Keywords
Writing PDF:Keywords
Writing PDF:Keywords
Writing XMP-dc:Creator
Writing XMP-pdf:Creator if tag exists
Improperly formed structure for XMP-iptcExt:Creator
Writing XMP-dc:Title
Writing XMP-pdf:Title if tag exists
Writing XMP-xmp:Title if tag exists
Writing XMP-crd:Description if tag exists
Writing XMP-crs:Description if tag exists
Writing XMP-dc:Description
Writing XMP-xmp:Description if tag exists
Writing XMP-dc:Subject
Writing XMP-xmpMM:Subject if tag exists
Writing XMP-dc:Subject
Writing XMP-xmpMM:Subject if tag exists
Writing XMP-dc:Subject
Writing XMP-xmpMM:Subject if tag exists
Writing XMP-pdf:Subject if tag exists
Writing XMP-acdsee:Keywords if tag exists
Writing XMP-pdf:Keywords
Writing XMP-xmp:Keywords if tag exists
Writing XMP-photoshop:CaptionWriter
Writing XMP-xmp:CaptionWriter
Rewriting T:/Temp/2025-06-17 09;49;56 - MAZE - Test/2025-06-17 09;49;56 - MAZE - Test.pdf...
  Editing tags in: PDF XMP
  Creating tags in: PDF XMP
    + PDF:Author = 'M Andr.. Z Eckenrode'
    + PDF:Keywords = 'keyword1'
    + PDF:Keywords = 'keyword2'
    + PDF:Keywords = 'keyword3'
    + PDF:Subject = 'This is a description'
    + PDF:Title = 'This is the title'
  Rewriting XMP
    + XMP-xmp:CaptionWriter = 'M Andr.. Z Eckenrode'
    + XMP-photoshop:CaptionWriter = 'M Andr.. Z Eckenrode'
    + XMP-dc:Creator = 'M Andr.. Z Eckenrode'
    + XMP-dc:Description = 'This is a description'
    + XMP-pdf:Keywords = 'keyword1; keyword2; keyword3'
    + XMP-dc:Subject = 'keyword1'
    + XMP-dc:Subject = 'keyword2'
    + XMP-dc:Subject = 'keyword3'
    + XMP-dc:Title = 'This is the title'
    1 image files updated

In any case, I'm using the exact same command with both the incorrectly and the correctly formatted versions of the JSON, and the correctly formatted version always gets imported successfully.
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: StarGeek on June 17, 2025, 08:32:43 PM
Ok, my apologies. I read your first post wrong and thought running the command with your test files came back as No SourceFile on both your JSON files. That was because I didn't CD to the test files' directory (I always run commands with full paths) and they both came back with that error.

I'd guess that because the JSON isn't formatted correctly, exiftool's JSON parser fails and can't find any tag names.

It'll be up to Phil to decide what to do here. But because this is only the second post where the Format error in JSON file has come up, with the other having to do with PowerShell forcing output as UTF-16, it might be pretty low on the to-do list.
Title: Re: ‘No sourcefile in imported JSON database’ but sourcefile correct
Post by: Phil Harvey on June 17, 2025, 09:26:03 PM
ExifTool couldn't import the JSON, so the "No sourcefile in imported database" warning was accurate.

I can see how this might be a bit misleading, but the format error should have been a big clue.

- Phil