What's wrong with my batch file?

June 29, 2013 at 06:19:42
Specs: Windows 7
I have got a couple of jpgs - some with gps data in the exif tag, others without. I would like to do some operations on the files depending on the presence of gps data. I just cannot find the error:

@echo off
del temp.txt
for /f "delims=" %%f in ('dir /b *.jpg') do (
set outputvar=
exiftool -GPSDateStamp "%%f" > temp.txt
set /p outputvar= < temp.txt

if outputvar=="" (
rem no GPS data
exiftool -CreateDate+=1 "%%f"

) else (
rem GPS data present
exiftool "-CreateDate<$GPSDateStamp $GPSTimeStamp" "%%f"
del temp.txt

Thanks, Andreas

See More: Whats wrong with my batch file?

Report •

June 29, 2013 at 10:04:26
muddypit7: I just cannot find the error
Well, the first step would be to identify what you want, and what you do get. Next step would be to compare what you wanted with what actually happened, and quantify the difference.

How To Ask Questions The Smart Way

Report •

June 29, 2013 at 11:35:57
In your IF statement, your "outputvar" needs to be a variable (yours is a string-constant whose value is outputvar, and it needs quotes around it unless they're supplied from the line from temp.txt. You may need to enable
delayedexpansion, but probably not.
SO, it should look something like this:
IF "!outputvar!" equ "" (
You can't use percents (%outputvar%), because you're inside a code-block. You might be able to skip the whole issue like this:

for /f "delims=" %%f in ('dir /b *.jpg') do (
for /f "tokens=*" %%a in ('exiftool -GPSDateStamp "%%f" ^&^& echo gps positive ^|^| echo gps negative') do (
if "%%a" equ "gps positive" (
) else (

Which would eliminate both the temp file and the outputvar in one throw, but it all depends on whether exiftool sets errorlevel or not.

Report •
Related Solutions

Ask Question