eyeball Posted January 12, 2006 Share Posted January 12, 2006 (edited) 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?? set SRCDIR=C:\Documents and Settings\Administrator\My Documents\My Picturesset DSTDIR=F:\backed_up_picturesfor /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 Edited January 12, 2006 by eyeball Link to comment Share on other sites More sharing options...
Grunth0s Posted January 12, 2006 Share Posted January 12, 2006 Xcopy is the command you are going to need.You can specify switches to cover sub folders.From a DOS prompt, do an XCOPY /? to find out the switches Link to comment Share on other sites More sharing options...
eyeball Posted January 12, 2006 Author Share Posted January 12, 2006 iv tried substituting copy for xcopy /e /s but when i run it it just gives me an error :S Link to comment Share on other sites More sharing options...
Synapse Posted January 13, 2006 Share Posted January 13, 2006 Xcopy Syntax: http://www.microsoft.com/resources/documen...n-us/xcopy.mspx Link to comment Share on other sites More sharing options...
eyeball Posted January 13, 2006 Author Share Posted January 13, 2006 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 Link to comment Share on other sites More sharing options...
Yzöwl Posted January 13, 2006 Share Posted January 13, 2006 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 populatingsingle 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_picturesmatchdir.zip Link to comment Share on other sites More sharing options...
eyeball Posted January 13, 2006 Author Share Posted January 13, 2006 Fantastic!!!!thats exactly what i wanted thank you so much you are a great programmer, next time your in the pub have a beer on me Link to comment Share on other sites More sharing options...
gunsmokingman Posted January 14, 2006 Share Posted January 14, 2006 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") ThenFso.CopyFolder( "PLACE_FOLDER_PATH_NAME_HERE" ) ,("PLACE_NEW_LOCATION_HERE")End If Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now