Jump to content

copy subfolders in a batch


Recommended Posts

hi all, i have the following batch file kindly made for me by Mr Snub but when i test it it doesnt copy sub folders and files only those in the root of the directory specified. can anyone tell me how to make it copy sub files and folders please?? :wacko:

set SRCDIR=C:\Documents and Settings\Administrator\My Documents\My Pictures

set DSTDIR=F:\backed_up_pictures

for /f "delims=" %%a in ('dir /b "%SRCDIR%"') do (

if not exist "%DSTDIR%\%%a" echo Copying %%a

if not exist "%DSTDIR%\%%a" copy "%SRCDIR%\%%a" "%DSTDIR%" > nul

)

thank you :D

Edited by eyeball
Link to comment
Share on other sites


with all due respect i am very capable of opening a command window and typing "xcopy /?" and that was the first thing i tried before i asked for help, but since advanced batch scripting is not my strong point i asked for help :)

so if anybody knows off the top of their head how to make this work please let me know.

thank you :D

Link to comment
Share on other sites

I have compiled a batch file which may suffice...

To use it, run the exe with two parameters, the first being the source directory and the second being the directory you need populating

single line run box example using your sample and with my exe in the root of E:

E:\matchdir.exe "C:\Documents and Settings\Administrator\My Documents\My Pictures" F:\backed_up_pictures

matchdir.zip

Link to comment
Share on other sites

Here is a vbs script that will do the same thing, but it checks for the folder

first is there then if it there it copies it.

Note: Please note there are quotes around the "path and name "

Dim Fso : Set Fso = CreateObject("Scripting.FileSystemObject")

If Fso.FolderExixts("PLACE_FOLDER_PATH_NAME_HERE") Then

Fso.CopyFolder( "PLACE_FOLDER_PATH_NAME_HERE" ) ,("PLACE_NEW_LOCATION_HERE")

End If

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...