Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

paste file into multiple directories & subs 1

Status
Not open for further replies.

hovercraft

Technical User
Jun 19, 2006
236
US
does anyone know of a way to copy a file into a directory and all of it's subs and their subs (if any) and their subs etc...

Is there a way to drag and drop?

Thanks,
Hovercraft
OS = Vista Ultimate SP2
 
Assuming that I understand correctly and that you have a logical reason to do this, drag & drop won't be very convenient. But a batch file should work fairly easily. Something like:
Code:
REM set variable for file to copy including path
set myfile="C:\path\file.ext"
REM set variable for path to top-level target directory
set toptarget="C:\somefolder1\somefolder2"
REM copy the file to all directories using recursive for loop
for /R %toptarget% %%i in (.) do (
copy %myfile% %%i
)
echo That was easy!
pause
cls

----
Steve
Small Business Support in the Connecticut River Valley of VT and NH
faq219-2884
MS Knowledgebase version: How to Ask
 
Steve - you are the pooh!

I have over 400 directories and within those directories are at least 3 more sub-directories. These folders represent customers who can access the directories via a web page. Sorta like an ftp site but I use a php script to display the contents of the directories.

Each folder has to have a copy of the php script in order to display it's contents.

If I make a change to the file I have to copy it to each directory and sub directory.

Your handy dandy batch file will save me (or someone else) hours! Thank you very much!!

Hovercraft.
 
You're welcome. Be sure to set the target to the level above the 400 directories.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top