Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   Dev Hardware ForumsSOFTWAREProgramming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Hardware Forums Sponsor:
  Trader Rating: 0 · #1  
Old July 2nd, 2008, 09:26 PM
arod arod is offline
n00b DevH'er
Dev Hardware Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 9 arod User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 5 m 56 sec
Reputation Power: 0
DOS Batch - Xcopy command help when dest. folder doesn't exist

I'm hoping someone can help me with some batch programming issues I'm having. I've set up a batch program that copies files with names containing a particular string from one source folder to a bunch of destination folders where they are required. The problem I am having is that I need the batch progam to have the commands to copy to every possible destination folder I may have, but when I actually run it the chances are some of the destination folders covered in the batch program won't actually exist.
At the moment when this is happening I'm asked whether I am trying to specify a folder or directory. I'm trying to figure out a way where if the destination folder doesn't exist the batch program will just skip over it and go to the next command.


Here's an example of my code:

FOR /R J:\"Source"\ %%G IN (*test1.docx) DO (xcopy "%%G" J:\"Destination1" /f /k)

FOR /R J:\"Source"\ %%G IN (*test2.docx) DO (xcopy "%%G" J:\"Destination2" /f /k)
...and so forth


So, if folder 'destination1' exists, it works fine. But assuming the 'destination2' doesn't exist it asks me to specify whether I am referring to a file or directory.

Does anyone know of some way I can make it so that if 'destination2' doesn't exist it just skips and goes onto the next line?

Thanks

Reply With Quote
  Trader Rating: 1 · #2  
Old July 3rd, 2008, 10:46 AM
weevilofdoom's Avatar
weevilofdoom weevilofdoom is offline
BLURG
Dev Hardware Loyal (3000 - 3499 posts)
 
Join Date: Sep 2004
Location: Oregon
Posts: 3,420 weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)weevilofdoom User rank is General 37th Grade (Above 100000 Reputation Level)  Folding Points: 32443 Folding Title: Starter FolderFolding Points: 32443 Folding Title: Starter Folder
Time spent in forums: 2 Months 23 h 55 m 21 sec
Reputation Power: 3411
Send a message via ICQ to weevilofdoom Send a message via AIM to weevilofdoom Send a message via MSN to weevilofdoom Send a message via Yahoo to weevilofdoom Send a message via Google Talk to weevilofdoom
I agree with what the guy said in the other forum you posted this in.

ha ha

On that note, try the /C switch - continue if errors occur.

Or the "/i" switch (that is an EYE, not an ELL) - If destination does not exist and copying more than one file, assumes that destination must be a directory.
__________________

Reply With Quote
Reply

Viewing: Dev Hardware ForumsSOFTWAREProgramming > DOS Batch - Xcopy command help when dest. folder doesn't exist


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway