• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

A little help with a DOS batch file *solved*

igowerf

Diamond Member
I wrote a batch file that uses ImageMagick to make thumbnail images.

@echo off

IF NOT EXIST thumbnails mkdir thumbnails

for /F %%i in ('dir /b /A-D *.jpg') do IF NOT EXIST thumbnails\%%i (
echo Creating thumbnail for %%i...
convert +profile "*" -quality 75 %%i -resize 95x71 thumbnails\%%i
echo Done.)

This seems to only work when the image filename does not have any spaces in it. If it has spaces, it'll input up to the space. Anyone know how to get it to take the full filename, including spaces? Thanks.
 
You're gonna need quotes in there somewhere, the tricky part might be WHERE!

I'd start with putting them around any instance of "%%i"

If %%i is part of a path put quotes around the whole path "thumbnails\%%i"

 
another thought...

use the shortnames to do this perhaps? check switches in the DIR command, I think it's /x or something.
 
Originally posted by: Smilin
another thought...

use the shortnames to do this perhaps? check switches in the DIR command, I think it's /x or something.

Thanks for the suggestions, but it seems that the /x switch can't be used with /b. "dir /x /b" will return the same thing as "dir /b".

I also tried the quotes in every instance of %%i, but that didn't work either. I tried both single and double quotes. The batch file would quit immediately after hitting a quoted %%i.
 
I got it. I had to replace the delimiter set in the FOR loop with something other than spaces and tabs. I used a / since that's an illegal filename character.
 
Back
Top