Re: Duplicating Files
- From: "Pegasus \(MVP\)" <I.can@xxxxxxxxxx>
- Date: Wed, 17 Sep 2008 00:10:49 +0200
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"
.
- Follow-Ups:
- Re: Duplicating Files
- From: Skippybox
- Re: Duplicating Files
- References:
- Duplicating Files
- From: Skippybox
- Re: Duplicating Files
- From: Pegasus \(MVP\)
- Re: Duplicating Files
- From: Skippybox
- Duplicating Files
- Prev by Date: Re: Removing XP
- Next by Date: RE: guest accounts and installing software
- Previous by thread: Re: Duplicating Files
- Next by thread: Re: Duplicating Files
- Index(es):
Relevant Pages
|