jpg check on a batch and skip a task

Hello I have this code someone helped me here:

@echo off
forfile /p "c:" /s /m *.pdf" >junk.text
for /f "tokens=1 delims=." %%F in ('type junk.txt') do (convert %%F.pdf" %%F.jpg")
del junk.txt

Open in new window


   This is the original link with all explanation and history:

http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/Q_28487439.html#a40232102

   Is working perfect no problem at all. What it does is look for PDF's inside all sub directories inside "c:\data\" then convert that pdf's to jpg and that jog is stored in the same directory the original pdf it is. For example we have just one sub directory inside "c:\data" called "one" it means "c:\data\one" and that sub directory "one" has 2 pdfs called 1.pdf and 2.pdf (of course is an example only names could be anything and sub directories is insde "c:\data" could be any number). Now if you run the script add inside "c:\data\one" 2 jpgs called 1.jpg and 2.jpg because like I mentioned before the converted jpgs must be with the name of the original pdf of where it was converted and saved in same location of that original pdf.
   Now the script does exactly like we want is prefect but someone could help us in add in the code a condition that if the jpg corresponding to one pdf exist in the directory and skip the conversion and continue with the other file and so on with all sub directories inside "c:\data" and all pdfs inside each sub directory of "c:\data". We want to do this because we add new sub directories to "c:\data" so frequent and there a re a lot of new sub directories and if we run the script process all and re-convert all the already converted files and there is no need to re-convert what it was converted because takes so long talking in days times.
   I hope someone can help.
Thank you
coerraceAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

oBdACommented:
That script can't work as listed. the "forfile" command should be "forfiles", and it will choke on any file that has more than one "." in it. Try it like this; the script is in test mode and will only display the "convert" commands it would normally run (and it will skip files for which a ".jpg" already exists). Remove the uppercase ECHO in line 7 to run it for real.
@echo off
setlocal
set SourceFolder=C:\Data
for /r "%SourceFolder%" %%a in ("*.pdf") do (
	echo Processing '%%~fa' ...
	if not exist "%%~dpna.jpg" (
		ECHO convert.exe "%%~fa" "%%~dpna.jpg"
	)
)

Open in new window

0
coerraceAuthor Commented:
oBdA appers is working just ine thing if you have source directory like "c:\data new exploration" with spaces not work it just worj for directories like ."c:\anydir" without spaces.
   Could you check to accept spaces in source directory?
Thank you
0
oBdACommented:
It should work for folders with a space in them as well; just don't add the quotes already when setting the variable:
@echo off
setlocal
set SourceFolder=C:\data new exploration
for /r "%SourceFolder%" %%a in ("*.pdf") do (
	echo Processing '%%~fa' ...
	if not exist "%%~dpna.jpg" (
		ECHO convert.exe "%%~fa" "%%~dpna.jpg"
	)
)

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
coerraceAuthor Commented:
Is working yes I was entering quotes "" is working all and script is more robust than o,d one to do the same.
Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.