0

I have a batch script to set XMP:Subject Exif tags on pictures in bulk.

tags.txt has all links of the pages and the tags. Links and Tags are separated by =.

This script should divide the URL and Tags divided by = remove the https://www. and all forward slashe / from it. And it will find a folder with this name.

Next, it should take the 2nd half of the tags.txt line, after =, and set that as XMP:Subject using exiftool on all jpg images.

Then it should go back and read the next line in tags.txt, which has different link and different tags.

but the problem is, its taking the tags from the 1st line in tags.txt and applying that to all images in all folders. Then it is taking the 2nd line tags, and setting these on all images in all folders.

Can someone please help me fix this issue?

:: bat file
:: V 4.0
@ECHO off
setlocal enabledelayedexpansion

set batpath=%~dp0


echo.>"!batpath!\log.txt"

For /F "usebackq tokens=1,2  delims==" %%a in (tags.txt) Do (
  set link=%%a
  set tags=%%b

for /f %%h in ('type weblinks.txt') do (
    set link=%%h


set foldername=!link:https://www.=!
set foldername=!foldername:/=!

cd /d !foldername!


for /f "tokens=*" %%G in ('dir /b *.jpg') do ( 

    
    set imagename=%%G
    rem echo "!imagename!"
    set imagenameonly=%%~nG
    set extn=%%~xG


"!batpath!\exiftool" -XMP:Subject="!tags!" "!imagenameonly!!extn!"

echo. ----------------------- !foldername!\!imagenameonly!!extn! ----->>"!batpath!\log.txt"
"!batpath!\exiftool" -XMP:Subject -a "!imagenameonly!!extn!" >>"!batpath!\log.txt"

    )

    del *.*_original

cd /d !batpath!


)
)
2

0

You must log in to answer this question.

Browse other questions tagged .