ExifTool Forum

ExifTool => Newbies => Topic started by: exif_inq on June 04, 2014, 02:07:58 PM

Title: Output redirection gives empty file?
Post by: exif_inq on June 04, 2014, 02:07:58 PM
I have a folder of pictures and I'd like to make a spreadsheet of their exif data. I tried the following code in the command line:

C:\Users\j\Desktop>exiftool -csv -filename -imagesize C:\Users\j\Desktop\test > output.csv

It creates a new file, but it's blank. When I add -k to the code, the window appears with all the relevant information about the pictures, so it's clearly not a problem reading the folder - it's just not writing it.

When I used -w txt with a single picture, it writes a file just fine. It's just when I'm using output redirection (the >), either with the folder or with a single picture, that I get a blank file in return.

I must be missing something obvious?



Title: Re: Output redirection gives empty file?
Post by: Phil Harvey on June 04, 2014, 02:50:28 PM
The redirection should work if you run the command inside a cmd.exe window.

The redirection is a function of the command shell (cmd.exe).

If you are executing this instead from inside some other software, you may need to handle the redirection yourself.

- Phil
Title: Re: Output redirection gives empty file?
Post by: exif_inq on June 05, 2014, 10:42:08 AM
Hi Phil, thanks for the response.

I am indeed running the command in a cmd.exe window; that's what makes this so baffling.
Title: Re: Output redirection gives empty file?
Post by: Phil Harvey on June 05, 2014, 10:49:46 AM
OK.  Try this:

echo "test" > out.txt

you should get a file called "out.txt" containing the word "test".

If this works, then try:

exiftool -echo "test2" > out2.txt

which should be equivalent (with a different output file so as not to get confused with the other one).

And if this works, then piping other exiftool commands should work too.

- Phil
Title: Re: Output redirection gives empty file?
Post by: exif_inq on June 05, 2014, 11:09:56 AM
The first command worked fine, but - once again, the second command created a blank file with nothing in it.

I'm beginning to suspect it might be something to do with the permissions on the computer - I'm running exiftool as an administrator, and it works perfectly fine for other commands, but perhaps there's something preventing it from writing in redirected files.

Thanks again for your help!
Title: Re: Output redirection gives empty file?
Post by: Phil Harvey on June 05, 2014, 11:25:32 AM
Wow, that's odd.

I can't see how it should matter what command you are using before the shell redirect, as long as the command was sending output to stdout, which ExifTool should be.

I'm at a bit of a loss here.

What version of Windows are you running?  Can you try this on another system?

- Phil

Edit:  Wait.  Can you confirm that this command works to print "test2" without the redirection?:

exiftool -echo "test2"
Title: Re: Output redirection gives empty file?
Post by: exif_inq on June 06, 2014, 10:43:31 AM
I tried using exiftool on another computer, using the exact same commands, and it worked perfectly. Both computers are running Windows 7 & in the same office, so it's still strange that one works and the other doesn't. But, at least it's working somewhere!

That command worked to print "test2" on the first computer, btw.
Title: Re: Output redirection gives empty file?
Post by: orax on June 06, 2014, 11:19:52 AM
And if you run the command with Powershell (or maybe cygwin) ? Same thing ?

echo "test1" >> a.txt
.\exiftool.exe -echo "test2" >> .\a.txt
cat .\a.txt
test1
test2
Title: Re: Output redirection gives empty file?
Post by: Phil Harvey on June 06, 2014, 05:56:25 PM
Quote from: exif_inq on June 06, 2014, 10:43:31 AM
I tried using exiftool on another computer, using the exact same commands, and it worked perfectly. Both computers are running Windows 7 & in the same office, so it's still strange that one works and the other doesn't. But, at least it's working somewhere!

That command worked to print "test2" on the first computer, btw.

OK.  So that only leaves something different in the settings between the two computers, which would point to something like you permission idea.  (Or, perhaps interference by some anti-virus software on the first computer?  -- I have seen before where some A.V. software locks the file and causes problems remotely similar to this.)

- Phil
Title: Re: Output redirection gives empty file?
Post by: bobslost2 on November 02, 2014, 12:12:27 AM
Hi - I have the same issue.  I think it is a strawberry perl/win7 64bit problem, not an Exiftool problem. See below:
F:\temp\play>type testit.pl
use strict;
use warnings;
print "this shoud be on stdout\n";

.\testit.pl > testit2.txt creates a zero length output file from the cmd shell shortcut installed with strawberry perl.  Same behaviour when I redirect exiftool output with this shell. The shortcut points to C:\Windows\SysWOW64\cmd.exe

if I use  C:\Windows\System32\cmd.exe no problems with redirection. So work-around:
exiftool.pl -a test.jpg > test.txt works fine from the shell created by the old [presumably 32bit] cmd.exe

Title: Re: Output redirection gives empty file?
Post by: Phil Harvey on November 02, 2014, 07:48:19 AM
Thanks for solving this question!

- Phil