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

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
marmourjr
Posts: 2
Joined: 08 Mar 2011 09:37

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

#1 Post by marmourjr » 08 Mar 2011 09:51

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")

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

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

#2 Post by aGerman » 08 Mar 2011 12:43

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

marmourjr
Posts: 2
Joined: 08 Mar 2011 09:37

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

#3 Post by marmourjr » 08 Mar 2011 13:14

I appericate the feedback. It's not working. I'll go back to the drawing board.

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

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

#4 Post by aGerman » 08 Mar 2011 13:33

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

Post Reply