if condition inside a for loop
Posted: 20 Jul 2014 18:59
hello everyone,
I want to loop through pdf files, find the ones that are portrait, and move them to a seperate folder.
pdftk is an executable that gives me this information, so when i type
for /f "tokens=2" %%a in ('pdftk %%g dump_data ^| find "PageMediaDimensions"') do (
set /a dim1=%%a
)
dim1 represents one of the dimensions and dim2 the other.
That part works well.
After, I just have to compare dim1 and dim2 to see if %dim1% GTR %dim2%, and if it is, move the file to the appropriate Folder
But... it doesn't work. I think the problem comes from using dim1 inside a for loop, it is not seen as a number
Any ideas ?
Thanks,
Audrey
for %%g in (*.pdf) do (
for /f "tokens=2" %%a in ('pdftk %%g dump_data ^| find "PageMediaDimensions"') do (
set /a dim1=%%a
)
for /f "tokens=3" %%b in ('pdftk %%g dump_data ^| find "PageMediaDimensions"') do (
set /a dim2=%%b
)
if %dim1% GTR %dim2% (
move %%g myFolder
)
)
I want to loop through pdf files, find the ones that are portrait, and move them to a seperate folder.
pdftk is an executable that gives me this information, so when i type
for /f "tokens=2" %%a in ('pdftk %%g dump_data ^| find "PageMediaDimensions"') do (
set /a dim1=%%a
)
dim1 represents one of the dimensions and dim2 the other.
That part works well.
After, I just have to compare dim1 and dim2 to see if %dim1% GTR %dim2%, and if it is, move the file to the appropriate Folder
But... it doesn't work. I think the problem comes from using dim1 inside a for loop, it is not seen as a number
Any ideas ?
Thanks,
Audrey
for %%g in (*.pdf) do (
for /f "tokens=2" %%a in ('pdftk %%g dump_data ^| find "PageMediaDimensions"') do (
set /a dim1=%%a
)
for /f "tokens=3" %%b in ('pdftk %%g dump_data ^| find "PageMediaDimensions"') do (
set /a dim2=%%b
)
if %dim1% GTR %dim2% (
move %%g myFolder
)
)