MSFN Forum: Simple Batch file to copy specific directories - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Simple Batch file to copy specific directories Rate Topic: -----

#1 User is offline   bbbngowc 

  • Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 09-August 06

Posted 01 October 2009 - 06:26 PM

Hi,

Just wondering how to copy directories where the name = ABC* and the files contained therein. I can do a dir /d ABC*, but I can't do a copy or xcopy ABC*\*.*

Any suggestions?


#2 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,249
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 01 October 2009 - 07:47 PM

for /f %%_ in ('dir /ad /b from\ab*') do xcopy from\%%_\*.* to\%%_\ /s /e

#3 User is offline   bbbngowc 

  • Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 09-August 06

Posted 24 October 2009 - 11:15 AM

Hi,

Thanks IcemanND for the help with the following command. I changed the xcopy to dir for a test before the copy, and it works, but why would it miss the folders with 'spaces' in the name? What's needed to so that it sees all the folders including those with space in the name?

for /f %_ in ('dir /ad /b c:\dir\*') do dir "c:\dir\%_\*.*"


#4 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,249
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 24 October 2009 - 06:42 PM

Add the tokens option to the for command.

for /f "tokems=*" %_ in ('dir /ad /b c:\dir\*') do dir "c:\dir\%_\*.*"

#5 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 9,105
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 25 October 2009 - 03:29 AM

Just in case :ph34r: :

View PostIcemanND, on Oct 25 2009, 02:42 AM, said:

for /f "tokems=*" %_ in ('dir /ad /b c:\dir\*') do dir "c:\dir\%_\*.*"


tokens

jaclaz

#6 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,249
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 25 October 2009 - 11:12 AM

OK, OK, I'll turn the spell checker back on. :blushing:

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy