Space in file name

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?".
Post Reply
codyhost

Space in file name

Post by codyhost »

I am having a problem with spaces in file names. I have researched the forums and cannot solve it. I see that the reference to the file names has to be in quotes, but with the snippet of script that I found in the FAQ's, I cannot seem to get it to work.

I am using Windows XP Professional and am using this command line script.

FOR %%a in (*.jpg) DO convert %%a -resize 600x400 -quality 85 c:\test\M\%%a

I have tried putting the double quotes around the *.jpg but it will not work.

All we are trying to do is batch process many files in a single directory and put the reduced files in another directory.

Any input would be appreciated.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Space in file name

Post by Bonzo »

There may be something that will help you out near the bottom of this page:
http://www.rubblewebs.co.uk/imagemagick/batch.php

Or something on this page:
http://www.imagemagick.org/Usage/windows/
codyhost

Re: Space in file name

Post by codyhost »

Bonzo wrote:There may be something that will help you out near the bottom of this page:
http://www.rubblewebs.co.uk/imagemagick/batch.php

Or something on this page:
http://www.imagemagick.org/Usage/windows/

I have reviewed these but see no handling of the spaces in the filenames.

Perhaps I am missing something obvious.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Space in file name

Post by el_supremo »

See: http://www.computerhope.com/forhlp.htm
Near the middle of the webpage it explains how to quote filenames which might contain spaces.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
codyhost

Re: Space in file name

Post by codyhost »

That got it.

Thanks.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Space in file name

Post by anthony »

codyhost wrote:
Bonzo wrote:Or something on this page:
http://www.imagemagick.org/Usage/windows/
I have reviewed these but see no handling of the spaces in the filenames.

Perhaps I am missing something obvious.
It is present in the IM example pages...
These modifiers can be combined, such that "%~dpn1" means "drive + path + name without extension and bracketing quotes". Consequently, we have to bracket the name by double quotes, such that the code also works for filenames including spaces. (If it doesn't, the quotes do no harm.)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply