Copy and rename with sequential number

May 19, 2010 at 23:21:27
Specs: Windows Vista
Hi,

I want to copy one .jpg file many times and rename it.

But is it possible to prompt me for the amount of copy's? And is it possible to prompt me for the new name?

For example: one photo named 3311AB_0001A_straat.jpg copy 30 times to another directory and name it 3311AB_0002A_straat.jpg, 3311AB_0003A_straat.jpg,
........ and further.

I'm a DOS dummy, but if anyone can help me here?

gr. Demeck


See More: Copy and rename with sequential number

Report •

#1
May 24, 2010 at 04:15:58
Hi Demeck,

Try this batch file, that iv scripted.

1. Start the batch file in the same directory of the JPG file.
2. Enter a new file name for the JPG file, in this case '3311AB_0001A_straat' (without extension).
3. Enter how many times you want copy the file.

The batch file will copy the JPG file default to %TEMP%, (directory can be changed in script.)
When the number of %INPUT% is done, it will tell you it's done.

The batch file:

@echo off
@mode con cols=60 lines=16
title Made by MUs (Batch Hobbyist)
color 0f

:: SET HERE THE DIRECTORY.

set DIRECTORY=%TEMP%

:: USER INPUT GUI HERE.

:USERINPUT
echo.
echo Enter the new file name. (WITHOUT EXTENSION! , (JPG))
echo.
echo That will be the copyed file default name.
echo.
set /p "NAME= > "
echo.
echo How many copy's you want make?
echo.
set /p "input= > "
set VAR=0

:: COMMAND LOOPS HERE.

:LOOP
set /a VAR=%ANVAR% + 1
set /a NUM=%input% - %input% + %VAR%
ren *.jpg %NAME%%NUM%.jpg
set ANVAR=%NUM%
copy %NAME%%NUM%.jpg %DIRECTORY% > nul
ping localhost -n 2 > nul
if exist %DIRECTORY%\%NAME%%input%.jpg goto EXIT
goto LOOP

:: EXIT HERE, IF %INPUT% FILES HAS BEEN COPYED.

:EXIT
echo.
echo Copied %input% JPG'S to %DIRECTORY%
echo.
echo Press any key to exit.
pause>nul
exit

That's all.

I hope I have enough helped you.

Kind regards,

Muhammed Us\MUs
Batch Hobbyist


Report •
Related Solutions


Ask Question