Page 1 of 1

How to Make more of the same file?

Posted: 17 Mar 2016 06:09
by TheHunterManX
So I want to make a buttload of the same png file name to make it easier on my behalf. Could someone tell me what is wrong with the code below?

Code: Select all

set Number=0
for %%a in (.) do set currentfolder=%%~na
echo. > "%currentfolder%.png"
for %%f in (*.png) do (
REM Sets file as the file name...
set File="%%~nf Sprite"
)
:A1
set /a Number=%Number%+1
echo. > "%File% %Number%.png"
if %Number% EQU 5 pause
if %Number% EQU 20 pause
if %Number% EQU 50 pause
goto A1

Re: How to Make more of the same file?

Posted: 17 Mar 2016 06:54
by foxidrive
Does this float your boat?

Code: Select all

@echo off
for %%a in (.) do set "File=%%~fna Sprite"
for /L %%a in (1,1,2000) do break>"%file% %%a.png"

Re: How to Make more of the same file?

Posted: 17 Mar 2016 07:05
by TheHunterManX
Looked like it would work, but after about 2 seconds the cmd closes, and nothing happens. Could it be that i am using windows xp? Probably not but it will not work

Re: How to Make more of the same file?

Posted: 17 Mar 2016 07:16
by foxidrive
It's using the path incorrectly.

This is more robust:

Code: Select all

@echo off
for %%a in ("%cd%") do set "File=%%~a\%%~na Sprite"
for /L %%a in (1,1,20) do break>"%file% %%a.png"

Re: How to Make more of the same file?

Posted: 17 Mar 2016 07:24
by TheHunterManX
Now it is ok. Also It took me about 30 seconds to clear 2000 png files.

Re: How to Make more of the same file?

Posted: 17 Mar 2016 07:51
by foxidrive
Excellent.

If it is every PNG file in the folder then this should be effective too.

Code: Select all

@echo off
for %%a in (*.png) do break>"%%a"