Batch Script to assign values

Started by Sylvain M., October 12, 2014, 04:06:21 AM

Previous topic - Next topic

Sylvain M.

Hello everyone,
Excuse me if the question has been asked before: I'm French and it's hard for me to read every issue.
I wish to write a script that exiftool do the following:
- Ask two variables "Longitude" & "Latitude" that the user must enter (1)
- Assign these 2 variables to the corresponding EXIF fields identified pictures of a folder (and its subfolders, maybe optional) (2)

For the (1), it's might be something like this :
echo off
cls
set /p LATITUDE= Latitude :
set /p LONGITUDE= Longitude :
cls
echo Assign LAT %LATITUDE% and LONG %LONGITUDE% to folder %1


(%1 because i would like to assign the folder by dragging on the script)

And for (2), something like this :
exiftool xmp:gpslatitude=%LATITUDE% -xmp:gpslongitude=%LONGITUDE% ...

but for now, I can not write things correctly.
But I started completely scripting!

Does someone could help me ?

Thanks a lot.

Sylvain M.

Phil Harvey

Hi Sylvain,

Your exiftool command looks good, except that you missed a leading "-", and you need to add the folder name:

exiftool -xmp:gpslatitude=%LATITUDE% -xmp:gpslongitude=%LONGITUDE% %1

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

Sylvain M.

It Works: great!
The script keeps the original copy of the images.
Can you tell me the procedure for not keeping it (even if it's dangerous, I admit).
Thank you so much!

Sylvain M.

[edit]
Excuse me, but I realize that the subfolders are not updated.
Can you also remember the procedure to update subfolders ? (if possible, to put an option in the settings required by the script)
[/edit]

echo off
cls
set /p LATITUDE= Latitude :
set /p LONGITUDE= Longitude :
cls
echo Assign LAT %LATITUDE% and LONG %LONGITUDE% to folder %1
exiftool -xmp:gpslatitude=%LATITUDE% -xmp:gpslongitude=%LONGITUDE% %1
rem arrĂȘt
pause

Phil Harvey

Quote from: Sylvain M. on October 12, 2014, 06:35:44 AM
Can you tell me the procedure for not keeping it (even if it's dangerous, I admit).

Add -overwrite_original to the command.

QuoteCan you also remember the procedure to update subfolders ?

Add -r

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

Sylvain M.