Re: Duplicating Files



Sorry, unless you post your modified version of the batch file plus a full
explanation of what exactly happened, I am unable to tell you what's
happened. Your reply "..couldn't get it to work" does not tell me anything.
Suffice it to say that I tested the program on my machine and it works as
expected.

Here is a brief explanation of each line of code:

set Source=d:\test folder
In this line you tell the program where the parent folder resides. The
parent folder is the home for your various subfolders containing the files
to be copied.

for /F %%a in ('dir /ad /b "%Source%"') do call :Sub %%a
This line picks up the various subfolders and tells the subroutine to
process one at a time

goto :eof
This line ends the main part of the batch file.

:Sub
This line says that we're now in a subroutine.

for /F %%b in ('dir /a-d /b "%Source%\%*\*.*"') do ^
echo copy /y "%Source%\%*\%%b" "%Source%\%*\Copy of %%b"
This is actually one long line, as indicated by the ^ continuation
character. It picks up one file at the time from the nominated folder and
creates a copy of it under a new name, by preceding its original name with
"Copy of". The word "echo" prevents anything permanent from happening, thus
forcing the batch file into a demo mode. To activate the batch file, this
double line must look like so:
for /F %%b in ('dir /a-d /b "%Source%\%*\*.*"') do ^
copy /y "%Source%\%*\%%b" "%Source%\%*\Copy of %%b"

pause
This line pauses the batch file so that you can see what's happening.

If you're not familiar with advanced batch files then there is not much
point in me explaining the exact syntax of each line. Just copy and paste
them as they are, and set the "Source" to suit your own environment.


"Skippybox" <Skippybox@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6AB78AB2-DAA7-4A80-AA65-FCBE057FB541@xxxxxxxxxxxxxxxx
I'm trying to rename select files, but I don't want to actually rename
them.
I want to retain the original named files, but create a second copy of
them
in the same folder that can be renamed in another program. Most batch
renamer programs either output a copy of all the files to another folder
or
overwrite the original files, neither of which I want. So, that is why I
need to create copies in the same folders, but for several folders in
several
locations at once. Impossible? I tried your batch file Pegasus (MVP),
but I
couldn't get it to work. I'm afraid I am not familiar with the syntax of
them. Unless you want to explain it, I would prefer to use a
copy/duplication program that may be available. I found a program caled
FileBoss which looks like it probably could do what I want, but I was
hoping
for freeware. Any ideas? Thank-you.

"Pegasus (MVP)" wrote:


"Skippybox" <Skippybox@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:AB1290FD-557B-4CD3-8A17-C6FB85935B77@xxxxxxxxxxxxxxxx
How would someone duplicate some or all of the contents of several
folders,
within those same folders all at once. What kind of program could I
use
for
this, preferrably freeware?

As an example, say I have three folders named 1, 2, and 3. Folder 1
contains files A, B and Z, folder 2 contains files C, D and Z, and
folder
3
contains files E, F and Z:

1> A, B, Z
2> C, D, Z
3> E, F, Z

How would you select all at once, the six files A through F, in the
three
folders 1 through 3, and end up with the following:

1> A, B, Copy of A, Copy of B, Z
2> C, D, Copy of C, Copy of D, Z
3> E, F, Copy of E, Copy of F, Z

I'm looking for something that makes this duplication task easier, as
this
would be tedious for several hundred folders. Thanks in advance!

This seems a rather strange request . . . Anyway, you could use this
batch
file:
@echo off
set Source=d:\test folder
for /F %%a in ('dir /ad /b "%Source%"') do call :Sub %%a
goto :eof

:Sub
for /F %%b in ('dir /a-d /b "%Source%\%*\*.*"') do ^
echo copy /y "%Source%\%*\%%b" "%Source%\%*\Copy of %%b"
pause

To activate the batch file, remove the word "pause" at the end and change
the line just above from

echo copy /y "%Source%\%*\%%b" "%Source%\%*\Copy of %%b"
to
copy /y "%Source%\%*\%%b" "%Source%\%*\Copy of %%b"





.



Relevant Pages

  • Re: USB drive problem
    ... Once per month I update the files using a batch file ... using this context for the copy command: ... that folder. ... The first problem I see is that there is no U or S switch for COPY. ...
    (alt.comp.hardware.pc-homebuilt)
  • XP batch File, command line Zip, how?
    ... will, zip a folder using XP?s own ... Below is an example of my simple Batch file: ... @echo off ... copy TestSource\*.* TestDest ...
    (alt.os.windows-xp)
  • Re: script on xp comp
    ... tried creating this batch file ... drive at first to make sure it is connecting then created the netlogon batch ... > saving logon script. ...
    (microsoft.public.windowsxp.network_web)
  • Re: WinXP. Unable to map home drive. Maps to root of share only.
    ... The \0 folder does exist - I will try to explain further... ... test it would work like a dream - but that would mean the server having ... > Your question about my second batch file is justified. ... >> I don't quite understand the 2nd script because its mapping to the ...
    (microsoft.public.win2000.networking)
  • Re: Dos batch file to sort files based on file names.
    ... The batch file you quote came out of my own kitchen. ... grab the remaining characters of the file name up to the ... then use this string for the target folder? ... I am try to get the report write to remove all spaces from her ...
    (microsoft.public.windows.server.scripting)