Main Menu

Combining 2 commands

Started by jeno, August 24, 2015, 10:23:52 PM

Previous topic - Next topic

jeno

Hello,

Thanks for creating such a great tool!
I am wondering how do I combine 2 commands so that I have the result in a single text file.

First command:
exiftool -m -p '$ManifestReferenceFilePath$/$/$PlateNames$/$/$FontName$/$/$FontFileName$/$/$Title$/$CreatorTool$/$ModifyDate' -sep $'\n'  Test_withPDF.ai > out.txt

This code is working as what I expected, this is what it looks like in the out.txt.
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_02H_EX_BM_T.psd
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_03H_EX_BM_T.psd
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_01H_EX_BM_T.psd

Cyan
Magenta
Yellow
Black
White
DIELINES
32130
30151
21341

ArialMT
Helvetica
Helvetica-Bold
MyriadPro

Arial.ttf
Helvetica.dfont
Helvetica.dfont
MyriadPro-Regular.otf

Test_withPDF
Adobe Illustrator CS6 (Macintosh)
2015:08:21 08:39:49+08:00


Now that I have a second command to extract barcode information which looks like this:
exiftool -a -XMP-egBarcL:all Test_withPDF.ai

Which give me an output of:
Barcodes Bar Width Reduction    : 0.030000
Barcodes Code                   : 4902430123457
Barcodes Device Compensation    : 0.000000
Barcodes Magnification          : 1.000000
Barcodes Resolution             : 0.000000
Barcodes Type                   : EAN 13
Barcodes Bar Width Reduction    : 0.050000
Barcodes Code                   : 000000000000
Barcodes Device Compensation    : 0.000000
Barcodes Magnification          : 1.000000
Barcodes Resolution             : 0.000000
Barcodes Type                   : UPC-A
Barcodes Bar Width Reduction    : 0.050000
Barcodes Code                   : 000000000000
Barcodes Device Compensation    : 0.000000
Barcodes Narrow                 : 1.000000
Barcodes Symbol Type            : Best_Fit
Barcodes Type                   : DATAMATRIX


Since I might have more than one barcode data in the file, how do I combine two of this commands into a single command?
I am using Mac 10.10.3 as my development machine and the actual implementation will be on Window server 2008 R2.

Thanks ~

Regards,
Jeno

Phil Harvey

Hi Jeno,

Do you want the output of the second command to go to "out.txt" too?  I'll assume you do.

You can't combine two different output formats in one command without using -execute, which will cause the file to be processed twice, but it will be faster than two commands by quite a bit because exiftool will only be launched once:

exiftool -m -p '$ManifestReferenceFilePath$/$/$PlateNames$/$/$FontName$/$/$FontFileName$/$/$Title$/$CreatorTool$/$ModifyDate' -sep $'\n' -execute -a -XMP-egBarcL:all -common_args Test_withPDF.ai > out.txt

- Phil

P.S.  You should update your Mac to 10.10.5 (no drawbacks as far as I can see, and you should get the security patches)
...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 ($).

jeno

Wow! This is too complicated for a newbie (at least for me). Thank you very much Phill! And yes, I would like the command to go to the same "out.txt". This make sense for me as I am using Exiftool to create 'reports' for every Adobe Illustrator document that I receive.

Regards,
Jeno

jeno

After few round of testing, I'm ready to implement this into production. The Production server is a Windows machine, may I know how to "translate" command into Windows bat? I've change the the double quote and stuff and I just can't figure out how to get the newlines working properly. 

Phil Harvey

Hi Jeno,

I don't know what you mean by "get the newlines working properly".  Can you elaborate on this problem?

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

jeno

I am getting this:
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_02H_EX_BM_T.psd$\n/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_03H_EX_BM_T.psd$\n/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_01H_EX_BM_T.psd
Cyan$\nMagenta$\nYellow$\nBlack$\nWhite$\nDIELINES$\n32130$\n30151$\n21341

ArialMT$\nHelvetica$\nHelvetica-Bold$\nWrigley

Arial.ttf$\nHelvetica.dfont$\nHelvetica.dfont$\nMyriadPro-Regular.otf

590700_8-419-2416-15_BM_S
Adobe Illustrator CS6 (Macintosh)
2015:08:20 12:26:14+08:00


Instead I want this:
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_02H_EX_BM_T.psd
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_03H_EX_BM_T.psd
/Users/jenoloo/Desktop/Jobs/Roland/10 August 2015/648979/590700_01H_EX_BM_T.psd

Cyan
Magenta
Yellow
Black
White
DIELINES
32130
30151
21341

ArialMT
Helvetica
Helvetica-Bold
MyriadPro

Arial.ttf
Helvetica.dfont
Helvetica.dfont
MyriadPro-Regular.otf

Test_withPDF
Adobe Illustrator CS6 (Macintosh)
2015:08:21 08:39:49+08:00

Barcodes Bar Width Reduction    : 0.030000
Barcodes Code                   : 4902430123457
Barcodes Device Compensation    : 0.000000
Barcodes Magnification          : 1.000000
Barcodes Resolution             : 0.000000
Barcodes Type                   : EAN 13
Barcodes Bar Width Reduction    : 0.050000
Barcodes Code                   : 000000000000
Barcodes Device Compensation    : 0.000000
Barcodes Magnification          : 1.000000
Barcodes Resolution             : 0.000000
Barcodes Type                   : UPC-A
Barcodes Bar Width Reduction    : 0.050000
Barcodes Code                   : 000000000000
Barcodes Device Compensation    : 0.000000
Barcodes Narrow                 : 1.000000
Barcodes Symbol Type            : Best_Fit
Barcodes Type                   : DATAMATRIX

Phil Harvey

The problem is that -sep $'\n' isn't doing what you want.  Putting a newline in the command line is tricky.  See FAQ 21a for some 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 ($).

StarGeek

I've tried using a line feed in as a -sep argument before and got nowhere with it on Windows.  But since it's being used in a -p, you could change the list type tags to -sep "\n" -p "${TAG;s/\\n/\n/g}" and that will convert the \n sep into actual line feeds.

Also, since this is ending up in a Windows Batch file, you might try something like in this StackOverflow answer.  No idea if it would work, but it might be worth trying.
* 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).

jeno

Thanks but still no luck, I guess it will be easier to do "append to file" since I am putting multiple list item together in a txt file

exiftool -m -p "$ManifestReferenceFilePath$/$/$PlateNames" -sep $"\n" "${TAG;s/\\n/\n/g}" %inputs% -w %%d%%f.txt

StarGeek

I was just giving you a generic template to fill in, not a command to directly add.  I have no experience the tags you're using so I didn't want to make assumptions.  Any place that you're using some sort of list type tag, replace TAG with that tag and add the rest.

For example
exiftool -m -p -sep "\n" "${ManifestReferenceFilePath;s/\\n/\n/g}$/$/$PlateNames" %inputs% -w %%d%%f.txt

If $PlateNames is also a list type tag, put a brace between the dollar sign and PlateNames and add ;s/\\n/\n/g} to the end of it.  Resulting in ${PlateNames;s/\\n/\n/g}.  Also note that I used -sep "\n", no dollar sign. 
* 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).

jeno

Thanks StarGeek, this is very helpful for a newbies, I managed get it to work with the command below:

exiftool -m -p "${ManifestReferenceFilePath;s/\\n/\n/g}$/$/${PlateNames;s/\\n/\n/g}$/$/${FontName;s/\\n/\n/g}$/$/${FontFileName;s/\\n/\n/g}$/$/${Title;s/\\n/\n/g}$/$/${CreatorTool;s/\\n/\n/g}$/$/${ModifyDate;s/\\n/\n/g}$/$/" -sep "\n" %inputs% -W+! %%d%%f.txt


However I'm not able to get -execute -a -XMP-egBarcL:all -common_args to work because I am using -W+! which make sense for my case to overwrite the existing txt file everytime the command is run. Also half of the time the data wasn't there (not every .ai file have this data), instead of append the -XMP-egBarcL:all data, this command would actually delete the whole txt file if -XMP-egBarcL:all data is not found or it would replace everything with only -XMP-egBarcL:all data if this data is found.