Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Can anyone tell me how to use the pipe (|) redirect to pipe paths and filenames into the xcopy command? Reason is because I want to move a couple hundred files, but not all files in those locations so I can't use *.* . And I don't want to have a separate xcopy line in my batch file for every file cause it would take forever to move all of them.

wow, thats pretty advanced for me. Where do I identify the source file-- inside the parentheses? can it be a .txt file or must it be zipped? and where do I identify the target location-- i:\Dir\ ? An item-by-item explanation of this command would be excellent so I could use it for other stuff too. And thanx for the reply!

Update:
Well, I've been playing around with your suggestion and found that the item(s) inside the parentheses must be relative to the location of the batch file that executes it. Also, "echo f" moved the file only, whereas "echo d" created a new folder with same name as file and put the file in it. So I cannot specify a different drive letter for source files. And sadly, the execution handled every file as individual xcopy commands, so they moved very sllloooowly. So I need a different approach to move these unrelated files from one drive to another and keep directory structure (no wildcards). Any more suggestions? (and thanx dtech!)

If the files truly are unrelated, then you would need to work from a list, using 'For.. In.. Do'. Creating the list would likely be just as time consuming as manually copying the files - not much benefit to that unless it's a recurring situation. I'm not sure that piping (or even xcopy specifically) is necessary. Xcopy.. copies - to move (copy & erase) there's the DOS 'move' command.
I'm not insensitive, I just don't care.

Hey jboy. Yer right, putting all my desired files(and with paths)into the command would be extremely cumbersome; and i'm sure dos will limit the number of characters in my command. But i'm not gonna give up just yet! There's GOT to be a way to do it using text file data and redirect it into either a command or a variable. Just gotta find a crafty way to do it. Problem at the moment is I don't understand the nature of the way dos defines and uses variables very well. But i'll be readin' up on it.

Hi
If you need paths won't something this do.@echo off
for %%a in (c:\SomeDir\*.ext) do echo d | xcopy %%a d:\SomeDir\%%aor if the d:\SomeDir already exists
@echo off
for %%a in (c:\SomeDir\*.ext) do xcopy %%a d:\SomeDir\%%a
%%a holds all the filenames the match ie
c:\SomeDir\*.ext wildcards could be used.
ie the "?" for one character and the "*"
for any characters
ie c:\SoneDir\*.txt or c:\SomeDir\t*.dat

Hi
Sorry the %%a on the on d:\SomeDir\%%a is not needed and will only add the path in the brackets to the d: path.

I use a combination of BASIC programs and batch files to move, copy, delete, create directories. The program has the rules,
ex. copy *.jpg to pic directory, delete files containg a string in a name, rename/renumber files, move subdirectories in sorted in order into n subdirectory groups. True it is slower to handle one file at a time, but since the process is untended it doesn't matter. I have handled up to 23,000 files in a batch, so a few hundred is not a problem. Actually it may not be worth the effort to make up the programs. I used the same process on 5 additional groups.

Yep. It looks like there's no way to do it without putting all my desired filenames into the "for-in-do" command, which wouldn't work anyway cause theres too many. I've already started a batch program to move them all individually to a place on harddrive, so I can burn the folders onto a cd and THEN use *.* to move the files into ramdrive(that's what i've been endeavoring to do this whole time). So I only have to wait this honkin' long time ONCE. Oh well, cant win 'em all. But thanks very much for your help, dtech jboy and wizard-fred!

9ballninja
Depending upon whether there is a pattern in your filenames, it may be relatively easy to make the name list(s).
In my previous example the 6 group had after processing, 234,102 files totaling 11.7 Gigabytes in 2,058 folders. This is greater than the original files since directories were created to store subdirectories of the files sorted in groups. Junk files were deleted, Those files selected were ordered and copied into groups. 995 batch files were created varying in size from 17000+ bytes to 180 bytes. The 17000 byte file has 893 command lines. 996 directory listings were created. Two master programs and 2 master batch files controlled the program flow. How do I know this? I didn't delete the program created lists and bat files in the original directories.
The first program created directory listings and batch files that controlled the processing through 4 levels deep.
Basically this automates the batch file and system commands that you would ordinarily type.
The program used the system functions of copy, delete, move, dir. The program was written in PowerBasic (similar to MS QuickBasic). Processing speed was about 3 hours.
The moral to this tale. That's what a computer is for. To do repeated tasks over and over. If you want to it completely in a batch try *nix script. I need the program to create the lists to produce the batch. Not an elegant solution but a working one.
It's time to learn a little programming.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |