Using FOR /R in recurisve file copies

A

ACutsumbis

I have a situation where nightly i need to copy to folders full of
files into all folders with in a certain directory. I know i need to
use the FOR /R command to do this.. However i'm have issues with it.

the folder structure looks as such
+MAIN
---+EMMCO
---+MASTER
---+USERS
--------+JaneDoe
--------------+LOCAL
--------------+EMMCO
--------+BobSmith
--------------+LOCAL
--------------+EMMCO
--------+JoeBlow
--------------+LOCAL
--------------+EMMCO

The Sub Folders in the USERS directory changes, but every night, i need
to copy Master to EACH user folder's LOCAL. And copy EMMCO to EACH
users EMMCO Folders.

I know the easiest way would be to execute 2 sepearate for /r commands,
but i'm having issues just getting one to work. Thank you.

I've tired the following FOR /R d:\Project\Folder\USERS\ %%X IN (.) DO
XCOPY d:\project\Folder\MASTER d:\Project\Folder\USERS\%%X\LOCAL\

Thank you for any help or suggestions
 
D

David Candy

%%X contains the full path

Type this at a command prompt
FOR /R d:\Project\Folder\USERS\ %X IN (.) DO Echo %X

Why are you using the for command at all. What are you hoping to do. Perhaps you want for /d

for /d %A in (c:\windows\*) do echo %~nxA
 
A

ACutsumbis

After a bit further research, i do think for /d is what i'm going to
need.

What i'm trying to accomplish is that in each user folder in USERS is
to replace 2 sub folders under each user everynight.
 
D

David Candy

I showed you how to get just the user name from the folder. The rest of your command should work now using /d and %%~nxX (see for's help - it is name and extension only).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top