Windows shortcut with a pipe

Started by elhiero, December 01, 2013, 01:18:05 PM

Previous topic - Next topic

elhiero

Hi all,
I'm french , difficult to choose right words for my question.

I created a shortcut for windows XP with this target :
%windir%\system32\cmd.exe /k  C:\util\exiftool.exe -a -u -g1 -G *.jpg   >> meta1.txt

And a second shortcut with this :
%windir%\system32\cmd.exe /k  C:\util\exiftool.exe -a -u -g1 -G *.jpg  |  find "animal"  >> meta2.txt

I use them with drag and drop.
The first one gives all metadata, no problem.

But the second one gives something like this
    <rdf:li>photo|animal|bird</rdf:li>

I expected something like this :
[XMP]           Last Keyword IPTC               : photo|animal|bird
[XMP]           Last Keyword XMP                : photo|animal|bird

What's the problem ?


I think that creating shortcuts beginning with cmd.exe /k could help other  users ...

Another question :
Using a BAT file with   %1   allows only  one file or a directory ?  If i want to drag 1 to 20 photos, is there a solution ?

Phil Harvey

I think I have more questions than answers:

1) I didn't know you could do redirection from within a Windows shortcut.

2) I don't understand why you specify "*.jpg" in the shortcut when you want to use the command with drag and drop.

3) I don't understand why you are using both -g1 and -G.  These options are contradictory.

4) I don't know why your 2nd command appears to give XML output.  It would do this if you used the -X option, but you aren't.  Is there any raw XML in the file that you can see without the 'find "animal"' pipe?

But I think I do have one answer:

Use "%*" in a BAT file to represent all of the arguments.  I think you should be using a BAT file instead of a shortcut anyway.

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

elhiero

#2
Thank you for this early response, here it's Sunday, 10:50 pm
I'm not sure for the answers following, but  I made sevreal tests

1) redirection is only possible  after invoking cmd.exe, it's the reason why I'm using this way
2) this shortcut is a shortcut for cmd.exe, then it seems that this one doesn't  receive any drag n drop jpg files, but exiftool that is started by cmd,  needs file names, so I wrote *.jpg
3) -g1 and -G is a mistake, I should use only -G, but  I still get the same results
4) no XML files nor raw

Now, instead of find "animal" , I wrote find "a"  to keep more results :
I got 200 K bytes of    jgvÒÕqV%"-ëžUªe¹wf 

I understand now that the whole jpeg file enters in the pipe
For comparison, in a command line window  this command : 
find "animal" dscn1403.jpg 
... gives the same lines containing xmp data

It seems difficult to use a pipe ...

I tried    (using  && to separate a second command)
%windir%\system32\cmd.exe /k  C:\util\exiftool.exe -a -u -g1 -G *.jpg   >> meta1.txt  &&  find "animal" < meta1.txt > meta1final.txt
.. doesnt'work.    Same result.  The first result file meta1.txt  is right

... and the following one gives very strange results (processing files in a sub directory, opening 5 image viewers etc ... )
%windir%\system32\cmd.exe /k  C:\util\exiftool.exe -a -u -g1 -G *.jpg   >> meta1.txt  &&  %windir%\system32\cmd.exe find "animal" < meta1.txt > meta1final.txt



I tried    (using  && to separate a second command)
%windir%\system32\cmd.exe /k  C:\util\exiftool.exe -a -u -g1 -G *.jpg   >> meta1.txt  &&  find "animal"  meta1.txt > meta1final.txt
This one is "nearly" a good solution.  I think that jpg files are still processed  by the  find "animal"  command , but  the  file  meta1.txt is now processed.

Phil Harvey

I thought that might be the problem.  I don't understand how a pipe works in the shortcut.

I still think a BAT file is the way to go.  Then the pipe would make sense and you can put the arguments where you want them.

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