If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Sophisticated(!) copying in DOS
Let's say I have ten files in a subdirectory, and I want to write a batch
file to copy ONLY five of them... The five I do NOT want to copy all start with the same letters in their filenames. The five I DO want to copy are all different. I cannot change this attribute, or the subdirectory in which they are stored. In other words, I have the following files: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil Ice Cream.fil Pizza.fil Beer.fil Accounts.fil Salary.fil I want to write a script that will copy "Ice Cream", "Pizza", "Beer", "Accounts", and "Salary", but that will SKIP the "ABC Jackson", "ABC Alias", etc. I know if I did "copy ABC*.fil" it would do the EXACT OPPOSITE of what I want... Is there a "contra"command that would pull this off? Thanks! |
Ads |
#2
|
|||
|
|||
Xcopy with the /exclude switch. Make a file listing what to exclude and
then use that as "file1" in the parameter list see XCOPY /? RJB wrote: Let's say I have ten files in a subdirectory, and I want to write a batch file to copy ONLY five of them... The five I do NOT want to copy all start with the same letters in their filenames. The five I DO want to copy are all different. I cannot change this attribute, or the subdirectory in which they are stored. In other words, I have the following files: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil Ice Cream.fil Pizza.fil Beer.fil Accounts.fil Salary.fil I want to write a script that will copy "Ice Cream", "Pizza", "Beer", "Accounts", and "Salary", but that will SKIP the "ABC Jackson", "ABC Alias", etc. I know if I did "copy ABC*.fil" it would do the EXACT OPPOSITE of what I want... Is there a "contra"command that would pull this off? Thanks! |
#3
|
|||
|
|||
Which begs the next question...
What is this "file listing" of which you speak? Is that like a mini-batch file? Thanks! "Bob I" wrote: Xcopy with the /exclude switch. Make a file listing what to exclude and then use that as "file1" in the parameter list see XCOPY /? RJB wrote: Let's say I have ten files in a subdirectory, and I want to write a batch file to copy ONLY five of them... The five I do NOT want to copy all start with the same letters in their filenames. The five I DO want to copy are all different. I cannot change this attribute, or the subdirectory in which they are stored. In other words, I have the following files: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil Ice Cream.fil Pizza.fil Beer.fil Accounts.fil Salary.fil I want to write a script that will copy "Ice Cream", "Pizza", "Beer", "Accounts", and "Salary", but that will SKIP the "ABC Jackson", "ABC Alias", etc. I know if I did "copy ABC*.fil" it would do the EXACT OPPOSITE of what I want... Is there a "contra"command that would pull this off? Thanks! |
#4
|
|||
|
|||
"RJB" wrote in message ... Let's say I have ten files in a subdirectory, and I want to write a batch file to copy ONLY five of them... The five I do NOT want to copy all start with the same letters in their filenames. The five I DO want to copy are all different. I cannot change this attribute, or the subdirectory in which they are stored. In other words, I have the following files: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil Ice Cream.fil Pizza.fil Beer.fil Accounts.fil Salary.fil I want to write a script that will copy "Ice Cream", "Pizza", "Beer", "Accounts", and "Salary", but that will SKIP the "ABC Jackson", "ABC Alias", etc. I know if I did "copy ABC*.fil" it would do the EXACT OPPOSITE of what I want... Is there a "contra"command that would pull this off? Thanks! Try this one-line batch file: @echo off for /f "tokens=*" %%* in ('dir /ad /b') do echo %%* | find /i "ABC" nul || echo xcopy "%%*" TargetFolder Remove the second "echo" to activate the command. |
#5
|
|||
|
|||
Did you read "XCOPY /?" ?
The file contains a list of what should be excluded. In this case ABC*.fil RJB wrote: Which begs the next question... What is this "file listing" of which you speak? Is that like a mini-batch file? Thanks! "Bob I" wrote: Xcopy with the /exclude switch. Make a file listing what to exclude and then use that as "file1" in the parameter list see XCOPY /? RJB wrote: Let's say I have ten files in a subdirectory, and I want to write a batch file to copy ONLY five of them... The five I do NOT want to copy all start with the same letters in their filenames. The five I DO want to copy are all different. I cannot change this attribute, or the subdirectory in which they are stored. In other words, I have the following files: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil Ice Cream.fil Pizza.fil Beer.fil Accounts.fil Salary.fil I want to write a script that will copy "Ice Cream", "Pizza", "Beer", "Accounts", and "Salary", but that will SKIP the "ABC Jackson", "ABC Alias", etc. I know if I did "copy ABC*.fil" it would do the EXACT OPPOSITE of what I want... Is there a "contra"command that would pull this off? Thanks! |
#6
|
|||
|
|||
Much nicer than my own suggestion!
"Bob I" wrote in message ... Did you read "XCOPY /?" ? The file contains a list of what should be excluded. In this case ABC*.fil RJB wrote: Which begs the next question... What is this "file listing" of which you speak? Is that like a mini-batch file? Thanks! "Bob I" wrote: Xcopy with the /exclude switch. Make a file listing what to exclude and then use that as "file1" in the parameter list see XCOPY /? RJB wrote: Let's say I have ten files in a subdirectory, and I want to write a batch file to copy ONLY five of them... The five I do NOT want to copy all start with the same letters in their filenames. The five I DO want to copy are all different. I cannot change this attribute, or the subdirectory in which they are stored. In other words, I have the following files: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil Ice Cream.fil Pizza.fil Beer.fil Accounts.fil Salary.fil I want to write a script that will copy "Ice Cream", "Pizza", "Beer", "Accounts", and "Salary", but that will SKIP the "ABC Jackson", "ABC Alias", etc. I know if I did "copy ABC*.fil" it would do the EXACT OPPOSITE of what I want... Is there a "contra"command that would pull this off? Thanks! |
#7
|
|||
|
|||
Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache.
I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. But I probably just want to do /EXCLUDE ABC*.fil Which is what your most recent post says. Right? Anyway, I think I have enough info to experiment with. Thanks, |
#8
|
|||
|
|||
Inline,
RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#9
|
|||
|
|||
At the risk of being redundantly monotonous and obtuse:
1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#10
|
|||
|
|||
BINGO! We have a Winner! :-) :-)
RJB wrote: At the risk of being redundantly monotonous and obtuse: 1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#11
|
|||
|
|||
I've tried every permutation I can think of, and the results I get a
Can't read file: XXX 0 File(s) copied (where XXX is whatever file comes after the "/exclude:" switch. The "donotcopy.txt" file is in the SOURCE directory, correct? Also, if I just try to exclude file(s) by name - a la /EXCLUDE:ABC*.fil, I get the same result... Can't read file: ABC*.fil 0 File(s) copied What the heck is going on??? "Bob I" wrote: BINGO! We have a Winner! :-) :-) RJB wrote: At the risk of being redundantly monotonous and obtuse: 1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#12
|
|||
|
|||
Let's see your precise command, and the contents of the
exclude file. "RJB" wrote in message ... I've tried every permutation I can think of, and the results I get a Can't read file: XXX 0 File(s) copied (where XXX is whatever file comes after the "/exclude:" switch. The "donotcopy.txt" file is in the SOURCE directory, correct? Also, if I just try to exclude file(s) by name - a la /EXCLUDE:ABC*.fil, I get the same result... Can't read file: ABC*.fil 0 File(s) copied What the heck is going on??? "Bob I" wrote: BINGO! We have a Winner! :-) :-) RJB wrote: At the risk of being redundantly monotonous and obtuse: 1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#13
|
|||
|
|||
It's all listed in the screens above
The donotcopy.txt contains a list - one per line - of each exclded file. The long and short is xcopy \\destinationpath\subdir /EXCLUDE donotcopy.txt \\receivingpath\subdirectory "Pegasus (MVP)" wrote in message ... Let's see your precise command, and the contents of the exclude file. "RJB" wrote in message ... I've tried every permutation I can think of, and the results I get a Can't read file: XXX 0 File(s) copied (where XXX is whatever file comes after the "/exclude:" switch. The "donotcopy.txt" file is in the SOURCE directory, correct? Also, if I just try to exclude file(s) by name - a la /EXCLUDE:ABC*.fil, I get the same result... Can't read file: ABC*.fil 0 File(s) copied What the heck is going on??? "Bob I" wrote: BINGO! We have a Winner! :-) :-) RJB wrote: At the risk of being redundantly monotonous and obtuse: 1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#14
|
|||
|
|||
From the xcopy help screen (xcopy /?):
XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W] [/C] [/i] [/Q] [/F] [/L] [/H] [/R] [/T] [/u] [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z] [/EXCLUDE:file1[+file2][+file3]...] /EXCLUDE:file1[+file2][+file3]... In other words: you have to place a colon after the parameter "exclude". If you still have problems, please quote your exact xcopy command, not a generic version, and the contents of the exclude file. "RJB" wrote in message news:8yvle.3534$zb.1928@trndny01... It's all listed in the screens above The donotcopy.txt contains a list - one per line - of each exclded file. The long and short is xcopy \\destinationpath\subdir /EXCLUDE donotcopy.txt \\receivingpath\subdirectory "Pegasus (MVP)" wrote in message ... Let's see your precise command, and the contents of the exclude file. "RJB" wrote in message ... I've tried every permutation I can think of, and the results I get a Can't read file: XXX 0 File(s) copied (where XXX is whatever file comes after the "/exclude:" switch. The "donotcopy.txt" file is in the SOURCE directory, correct? Also, if I just try to exclude file(s) by name - a la /EXCLUDE:ABC*.fil, I get the same result... Can't read file: ABC*.fil 0 File(s) copied What the heck is going on??? "Bob I" wrote: BINGO! We have a Winner! :-) :-) RJB wrote: At the risk of being redundantly monotonous and obtuse: 1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
#15
|
|||
|
|||
From the help
" /EXCLUDE:file1[+file2][+file3]... Specifies a list of files containing strings. Each string should be in a separate line in the files. When any of the strings match any part of the absolute path of the file to be copied, that file will be excluded from being copied. For example, specifying a string like \obj\ or .obj will exclude all files underneath the directory obj or all files with the .obj extension respectively." So /EXCLUDE:dontcopy.txt NOT /EXCLUDE dontcopy.txt Since where you put the file resulted in "can't read xxx", I suggest putting "dontcopy.txt" in a directory that is listed in the PATH listing. RJB wrote: It's all listed in the screens above The donotcopy.txt contains a list - one per line - of each exclded file. The long and short is xcopy \\destinationpath\subdir /EXCLUDE donotcopy.txt \\receivingpath\subdirectory "Pegasus (MVP)" wrote in message ... Let's see your precise command, and the contents of the exclude file. "RJB" wrote in message ... I've tried every permutation I can think of, and the results I get a Can't read file: XXX 0 File(s) copied (where XXX is whatever file comes after the "/exclude:" switch. The "donotcopy.txt" file is in the SOURCE directory, correct? Also, if I just try to exclude file(s) by name - a la /EXCLUDE:ABC*.fil, I get the same result... Can't read file: ABC*.fil 0 File(s) copied What the heck is going on??? "Bob I" wrote: BINGO! We have a Winner! :-) :-) RJB wrote: At the risk of being redundantly monotonous and obtuse: 1) Create a notepad file 2) In the file, type: ABC Jackson.fil ABC Smith.fil ABC Alias.fil ABC Lost.fil ABC Polar.fil 3) Save it as "filelist.txt" 4) In the xcopy command, XCOPY \\PATH\SOURCE_SUBDIRECTORY /EXCLUDE filelist.txt \\PATH\TARGET_SUBDIRECTORY /d /h /p /r /u /k /y Close? "Bob I" wrote: Inline, RJB wrote: Yeah, I gotta say, Pegasus, your solution gives me an ice cream headache. I still don't know if I get the "file listing" info... From your initial post, it seems as if I am creating a file - called "file1" - and in that file it includes a list of excluded files. CORRECT But I probably just want to do /EXCLUDE ABC*.fil Wrong, should be like this XCOPY /EXCLUDE FILELIST.TXT FILELIST.TXT contents are ABC*.fil one entry per line, you may have to experiment with it a bit. Which is what your most recent post says. Right? nope. Anyway, I think I have enough info to experiment with. Thanks, |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Copying Picture Files to CD | momofone | Windows XP Help and Support | 1 | May 5th 05 04:59 AM |
Problem copying files from one hard drive to another in XP Home | sebc03 | Hardware and Windows XP | 1 | March 31st 05 06:51 PM |
Computer slowing down when copying files | CM | New Users to Windows XP | 1 | February 6th 05 10:09 PM |
SP2 and RAID | Johannes Kantelberg | Windows Service Pack 2 | 6 | September 3rd 04 07:57 PM |
Error Copying File XP Install | Clayton | General XP issues or comments | 4 | August 13th 04 10:18 PM |