Please register or login. There are 3 registered and 834 anonymous users currently online. Current bandwidth usage: 95.85 kbit/s July 04 - 10:36pm EDT 
Hardware Analysis
      
Forums Product Prices
  Contents 
 
 

  Latest Topics 
 

More >>
 

    
 
 

  You Are Here: 
 
/ Forums / Programming /
 

  Help with a .bat file 
 
 Author 
 Date Written 
 Tools 
Jay Curtis Oct 03, 2007, 09:09pm EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List Replies: 9 - Views: 127
ok so Im writing a bat file to move everything from a folder name Docs (F:\Docs) from an external drive to the hard drive my computer (C:\Docs). I wrote this batch file but my problem is its not moving the subfolders in F:\Docs its only moving the files in that folder to C:\Docs

@echo off
goto start
:Redo
echo Press any key to repeat to move Docs Folder into C:\Docs...
pause>null
:Start
F:
echo Press any key to move Docs Folder into C:\Docs...
pause>null
echo Press any key to copy all contents in the folder Docs to the C:\Docs...
pause>null
C:
mkdir C:\Docs
goto Performcopy
:Performcopy
copy F:\Docs C:\Docs
goto Redo

so when this batch file is done I want all the files and the subfolders in C:\Docs
Can anyone tell me how to move the subfolders too =)


Want to enjoy less advertisements and more features? Click here to become a Hardware Analysis registered user.
Jay Curtis Oct 03, 2007, 09:11pm EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
hahaha part of my code made a face =) but the code is : performcopy but with out the space

FordGT90Concept Oct 03, 2007, 09:49pm EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List

Edited: Oct 03, 2007, 09:56pm EDT

 
>> Re: Help with a .bat file
You'll need a FOR loop:
http://www.computerhope.com/forhlp.htm

And a DIR command to get the list of sub directories:
http://www.computerhope.com/dirhlp.htm


Maybe:
FOR /R F:\Docs %%f IN (dir %%f) DO copy %%f C:\Docs\%%f

Chris M Oct 03, 2007, 10:13pm EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
Can't you just use wildcards(*) or is that Linux only?

--
It is said that when it comes to life, those who feel see it as a tragedy. Those who think see it as a comedy.
Dr. Peaceful Oct 04, 2007, 01:07am EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
Use "xcopy F:\Docs C:\Docs". Done.

It's equivalent to "cp -R" in linux, which copies recursively files in the entire directory tree.

____________________________________________
"May the people and the government respect the rights of all. Between individuals, as between nations, peace means respect for the rights of others." - Benito Juarez
FordGT90Concept Oct 04, 2007, 03:04am EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List

Edited: Oct 04, 2007, 03:05am EDT

 
>> Re: Help with a .bat file
I expected there to be a flag on the copy man to fulfill that purpose but didn't find one. I knew there had to be a recursive copy somewhere.

DublinGunner Oct 04, 2007, 07:01am EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
xcopy - now there's a blast from the past.


Could you not just use explorer? Or have you no OS installed?

E6400 L628 @3.4
Thermalright Ultra 120 Extreme
Abit Quad GT
2GB Team Xtreem DDR2-850 4 4 3 10
Leadtek 8800GT 512
OCZ GameXstream
Scott Harris Oct 08, 2007, 12:58pm EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
i have a similar batch i need to run. i have 1600 folders containing 2 files. i need to copy just those files in each folder to another single folder. i cannot program my way out of a paper bag so i need help. any ideas?

FordGT90Concept Oct 08, 2007, 07:20pm EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
FOR /R C:\test1 %%f IN (*.*) DO copy "%%f" "C:\test2\%%~nf%%~xf"

Just replace "C:\test1" to the directory you want to copy from and change "C:\test2\" to the directory you want to copy to. It will copy all files found in test1 (including subdirectories) in the directory of test2. It will overwrite existing files as it copies.

Scott Harris Oct 09, 2007, 07:13am EDT Reply - Quote - Report Abuse
Send Message - Add to Buddy List  
>> Re: Help with a .bat file
holy copy batchman, that worked!


Write a Reply >>


 

    
 
 

  Topic Tools 
 
RSS UpdatesRSS Updates
 

  Related Articles 
 
 

  Newsletter 
 
A weekly newsletter featuring an editorial and a roundup of the latest articles, news and other interesting topics.

Please enter your email address below and click Subscribe.