I am trying to determine (thus far unsuccessfully) the syntax so that I can import the contents of a text file ("text.txt") into the PDF "description" tag of a pdf document ("test_document.pdf").
perhaps something like this....?
exiftool -XMP-dc:Description<=@C:\file\path\to_\text.txt path\to\test_doc\test_document.pdf
If this is possible, could this process then be done in a batch process permitting multiple unique pdf files to each have a unique text file write to them?
I'd appreciate any suggestions. Thanks.
-John
You almost have it. See the
-TAG<=DATFILE option (https://exiftool.org/exiftool_pod.html#TAG-DATFILE-or--TAG-FMT). You also need to put quotes around that part so the command line doesn't interpret the less than sign
< before exiftool can use it.
Quote from: jma1966 on February 09, 2024, 10:51:09 AMIf this is possible, could this process then be done in a batch process permitting multiple unique pdf files to each have a unique text file write to them?
As per the docs in that link, you can use
%d,
%f, and
%e represent the directory, file name and extension of the original PDF so that you can create the name of the text file. Assuming that the text file is in the same directory as the PDF and the same base name, your command would be something like
exiftool -ext pdf "-XMP-dc:Description<=%d%f.txt path\to\PDF_Dir\This would process all the PDFs in "PDF_Dir", look for a matching .txt in the same directory and the same base name, and copy the entire contents into the
Description tag. See the
-w (
-TextOut) option (https://exiftool.org/exiftool_pod.html#w-EXT-or-FMT--textOut) for more details on the percent variables.
This command creates backup files. Add
-Overwrite_Original (https://exiftool.org/exiftool_pod.html#overwrite_original) to suppress the creation of backup files. Add
-r (https://exiftool.org/exiftool_pod.html#r-.--recurse) to recurse into subdirectories.
Also take note that any changes exiftool makes to a PDF are reversible because exiftool uses the Incremental Update feature (https://www.debenu.com/kb/incremental-updates/) of PDFs to make changes. The file needs to be re-linearized to make the changes permanent and remove any previous data. See the PDF Tags page (https://exiftool.org/TagNames/PDF.html) for details.
Thank you again! Your help was spot on---and is very much appreciated.
--John