Discussion:
Help With Robocopy & Source Folders Using A Wildcard
(too old to reply)
Q
2024-01-30 19:56:02 UTC
Permalink
I am trying to robocopy all the folders in a folder which start with
"P-" to a network share. I understand Robocopy does not work using
wildcards in the source folder. How can I do this in a batch using a
For command? I tried

For /d %%a in ("d:\folder source\P-*") Do Robocopy "%%a" "\\unc path to
folder\data\%%a" /variousrobocopyswitches

but %%a is picking up the entire path and trying to use it as the
destination. I only need the folders that start with "-P" to be copied
to the "data" folder that lives in the destination path. How do I
separate the "P-" folders found from the source path?
Robert Roland
2024-01-31 12:50:49 UTC
Permalink
Post by Q
How do I
separate the "P-" folders found from the source path?
In the help text for for (for /?), all the way at the bottom,
substitution of variable references is explained.

In your destination path, replace %%a with %%~na.
--
RoRo
Q
2024-01-31 17:34:25 UTC
Permalink
Post by Robert Roland
Post by Q
How do I
separate the "P-" folders found from the source path?
In the help text for for (for /?), all the way at the bottom,
substitution of variable references is explained.
In your destination path, replace %%a with %%~na.
Thank you Robert!
Zaidy036
2024-02-01 02:06:58 UTC
Permalink
Post by Q
Post by Robert Roland
Post by Q
How do I
separate the "P-" folders found from the source path?
In the help text for for (for /?), all the way at the bottom,
substitution of variable references is explained.
In your destination path, replace %%a with %%~na.
Thank you Robert!
if this is a one time use then first COPY all "P-" files to another
folder and RoboCopy from there.
Q
2024-02-01 12:01:49 UTC
Permalink
Post by Zaidy036
Post by Q
Post by Robert Roland
Post by Q
How do I
separate the "P-" folders found from the source path?
In the help text for for (for /?), all the way at the bottom,
substitution of variable references is explained.
In your destination path, replace %%a with %%~na.
Thank you Robert!
if this is a one time use then first COPY all "P-" files to another
folder and RoboCopy from there.
This will be run daily. The %%~na works in my testing. They haven't
started using it in production yet but I think it will work. Thank you
for that tip.

Loading...