Page 1 of 1

Search Local Drive and Copy new Folder from Network Drive...

Posted: 08 Mar 2011 09:51
by marmourjr
I am a newbie to writing DOS batch files. I've been doing countless research on this script and it's becoming futile. I am wanting a script that will search the local drive for a folder (parasysinfo). If this folder is found, I am wanting the script to copy the new folder from my network drive and replace the folder on my local drive. Can you please help me figure this out? Thank you in advanced.

This is what I have so far...

@echo off
setLocal DisableDelayedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/s/a-d c:\parasysinfo') do (move /y
G:\\filer01\depthome\Paratran\MARK\parasysinfo "%%a")

Re: Search Local Drive and Copy new Folder from Network Driv

Posted: 08 Mar 2011 12:43
by aGerman
The space behind delims= split the path if it contents spaces. Remove it.
/a-d excludes folders, you need /ad.

Untested:

Code: Select all

for /f "tokens=* delims=" %%a in ('dir /b /s /ad c:\parasysinfo') do (
  move /y "G:\filer01\depthome\Paratran\MARK\parasysinfo" "%%a"
)

Regards
aGerman

Re: Search Local Drive and Copy new Folder from Network Driv

Posted: 08 Mar 2011 13:14
by marmourjr
I appericate the feedback. It's not working. I'll go back to the drawing board.

Re: Search Local Drive and Copy new Folder from Network Driv

Posted: 08 Mar 2011 13:33
by aGerman
OK, step by step.

Code: Select all

@echo off &setlocal
for /f "tokens=* delims=" %%a in ('dir /b /s /ad c:\^|findstr /iec:"\parasysinfo"') do echo %%a
pause

Will this output the right path?

Regards
aGerman