1.

Solve : Duplicating-Need help Fast?

Answer»

I have 10 files, i need them duplicated X times, meaning, if i say 100 it will take the 10 and make 100 copies of each with UNIQUE names, even if the X is hard-coded in the script. So it's just a loop that copies the original to a new name with an increasing number. Not sure, I am new to DOS.Code: [Select]@echo off
setlocal ENABLEDELAYEDEXPANSION
set A=1
set /p L=enter name of file to be copied:
set M=%L:~-3%
set /p N=enter number of times you want to copy files:
for /L %%N in (1,1,%N%) do (
xcopy %L% %L%-!A!.%M%
set /a A+=1
)

FBThanks for the help, what does each line dofor many files this will WORK better:

Code: [Select]@echo off
setlocal ENABLEDELAYEDEXPANSION
set M=1
set /p N=enter number of times you want to copy files:
for /f "delims==" %%A in ('dir /b /a-d') do (
set L=%%A
set O=!L:~-3!
for /L %%N in (1,1,%N%) do (
xcopy "!L!" "c:\copies\!L!-!M!.!O!"
set /a M+=1
)
set /a M=1
)
exit
i'll go through it.

@echo off - turns echoing off so everything doesn't get copied to the screen
setlocal ENABLEDELAYEDEXPANSION - LETS you use variables in the for loop.
set M=1 - sets the copy number to 1
set /p N=enter number of times you want to copy files: - sets the number of copies you want to the variable N
for /f "delims==" %%A in ('dir /b /a-d') do ( - does the copy command for all the files in the current folder *you will need to copy this .bat file to the folder containing the files you want copied.*
set L=%%A - sets the current file to variable L
set O=!L:~-3! - sets tht files extension to variable O
for /L %%N in (1,1,%N%) do ( - for loop allows you to do one command lots of times
xcopy "!L!" "c:\copies\!L!-!M!.!O!" - copies files *you may want to change the directory to which the files are copied*
set /a M+=1 - adds one to the copy number
set /a M=1 resets copy number for the next file.

FBWhen I tried to copy files, it was working but it was not behaving when i tried to exit. There was no way to find out if the copy actually worked in the end. What am i doing wrong. I am just trying to copy X amount of files from a set directory, but I want to be able to run the script from other locations as well without having to change the path. not behaving when you tried to exit? what was happening?

xcopy should output something like Quote

1 file(s) copied succesfully
if it's worked or Quote
0 file(s) copied
if it's not worked.

to be able to run the script from anywhere add this line just above: "set /p N=enter number of times you want to copy files: " Code: [Select]set /p J=what directory are you're files located in:
cd %J%

FBIts output was 0 file(s) copied. This is the current code right now. So something not happening in xcopy, and when i want to exit by hitting ctrl c, it displays "does D:\. specify a file name or directory name on the target. Even when i try to run it off of a 4NT window, it lets me type the number of copies i want, then the window disappears.

@echo off
setlocal ENABLEDELAYEDEXPANSION
set M=1
set /p J=what directory are you're files located in:
cd %J%
set /p N=enter number of times you want to copy files:
for /f "delims==" %%A in ('dir /b /a-d') do (
set L=%%A
set O=!L:~-3!
for /L %%N in (1,1,%N%) do (
xcopy "!L!" "d:\.\!L!-!M!.!O!"
set /a M+=1
)
set /a M=1
)
exit presumably d:\. exists? when i try and run the script i get 'invalid path'.

I don't know about escape characters for xcopy. sorry

FBWell, when i run it, it asks for the directory and number of copies, then i enter the number than i get:

error error
error error
error error
error error

this is the xcopy, i SORT of modified it, xcopy "!L!" "xcopy d:\*.* /a /e /k, so i just need a way for the file to copy and with the same name and incrementing number. Just as if you copy and paste, it creates . can you put Code: [Select]REM infront on @echo off to see what exactly the error message is. Also the script i gave first of all gave an output which would be the original filename with a copy number like: . !L! is the filename !M! is the copy number and !O! is the extension.

FBOkay, i put that BACK, the REM displays the set m=1 and i put the path and number of copies, the script runs but it closes once it copies, where do i see if it copied the file or if it didnt copy the files

REM @echo off
setlocal ENABLEDELAYEDEXPANSION
set M=1
set /p J=what directory are you're files located in:
cd %J%
set /p N=enter number of times you want to copy files:
for /f "delims==" %%A in ('dir /b /a-d') do (
set L=%%A
set O=!L:~-3!
for /L %%N in (1,1,%N%) do (
xcopy "!L!" "d:\*.*\!L!-!M!.!O!"
set /a M+=1
)
set /a M=1
)
exit either put a "pause" after the xcopy, or delete the 'exit' and run it from cmd. Also i'm still not sure what *.* is?

FB


Discussion

No Comment Found