Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
I am trying to convert PDF files into jpg but only if it has 1 page. So I have run successfully both the command to identify the page and convert files. However, I could get it to work together in a bat file. I am trying to use this code. This bat file is put in a folder of many pdf, and the code seems to identify them correctly. I have not get to the part of conditional conversion yet. The comment out part was working by itself, before get nested.
pause
set path="C:\Program Files\ImageMagick-7.0.8-Q16\";%path%
FOR /r %%g in (*.pdf) DO (
for /f %%i in ('identify -format %n %%g') do set pgs=%%i
echo %pgs%
echo "%%g"
::convert %%~ng%%~xg %%~ng.jpg
::del %%~ng.pdf
)
pause
It keeps saying the syntax of the command is incorrect. But I tried the "identify..." in command prompt is working correctly. I don't work with command line very often.
SETLOCAL EnableDelayedExpansion
pause
set path="C:\Program Files\ImageMagick-7.0.8-Q16\";%path%
FOR /r %%g in (*.pdf) DO (
for /f %%i in ('identify -format %%n %%g') do set pgs=%%i
echo !pgs!
::convert %%~ng%%~xg %%~ng.jpg
::del %%~ng.pdf
)
pause
snibgo wrote: ↑2018-10-22T18:45:07-07:00
You can put "rem" inside loops, but not "::".
As you are learning the basics of BAT scripting, I suggest you find a good manual or webpage on the subject.
Your suggestion is correct. This language seems to be far stricter and precise in structure compare to the languages that I am familiar with. Do you happen to know a good source for it? Since my knowledge of the subject is very limited, I would hardly know which one is good.
Also, for some image, this conversion don't look very good (quite pixelated), is there a parameter that I could use to improve that? (there are so many complex options)