News:

Tekforums.net - The improved home of Tekforums! :D

Main Menu

Batch optimising images from command line/context menu

Started by Clock'd 0Ne, July 04, 2011, 10:52:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

XEntity

Hmm... maybe it's an admin rights thing as I'm on W7HP but logged in as administrator?

Does adding my command line work?

I've also noticed however that it doesn't like spaces in file names or the folder that it is sat within?

Clock'd 0Ne

I always do directory/filenames in 802.3 format, otherwise you have to remember to enclose them in speech marks, e.g. "C:\Program Files\" or C:\Progra~1\

Having said that, it works fine for me once I've cd\ into the correct directory, which does have spaces in, and I've not done any of that... and I've just worked out why!
I wasn't in the system directory as I thought, it was just that the directory had a space in, so when I did the cd\ it was reading the directory with 802.3 format how I typed it, not with spaces.

Without changing directories:
IF EXIST "%CD%\OLD\" GOTO FINDNEW works
IF EXIST %CD%\OLD\ GOTO FINDNEW doesn't :)

Also, backslashes, not forward slashes, or it gets confused

XEntity

Also don't forget to make a similar change on the png script as well otherwise it doesn't like spaces in the PNGs..

I've also used %~dp0 as apparently that plays a little nicer, although might only be UNC.. which wont work as the current director can't be set as a UNC path, unless you put in a check to then map a network drive!  :worried:

Here's the full updated code anyway that will take spaces etc...

echo off
cd %~dp0
cls

echo. Awesome-O PNG Converter
echo. ~~~~~~~~~~~~~~~~~~~~~~~~~
echo.

echo. Checking "OLD" folder exists
echo. ##################################
echo.
IF EXIST "%~dp0OLD/" GOTO FINDNEW
echo.
echo. Not found! You need to have a subfolder called "OLD" to convert dumbass!!
echo.
echo.

goto END

:FINDNEW

echo. That's a good start...
echo.
echo.
echo. Checking "NEW" folder exists
echo. ##################################
echo.

IF EXIST "%~dp0NEW/" GOTO FOUND

MKDIR NEW

echo. Folder not found so I created one!
echo. ##################################
echo.

goto COMPRESS

:FOUND
echo. We're on a roll!
echo.
echo.

:COMPRESS

echo. Getting busy making some PNGs!
echo. ##################################
echo.

for %%I in (old/*.*) do pngout "%~dp0OLD/%%I" "%~dp0NEW/%%I"

echo.
echo. All done sir!
echo.
echo.

:END

pause