Computing.Net > Forums > Disk Operating System > using pipe ( | ) with xcopy command

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

using pipe ( | ) with xcopy command

Reply to Message Icon

Name: 9ballninja
Date: February 17, 2005 at 15:26:03 Pacific
OS: win98
CPU/Ram: amd900mhz 512
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: dtech10
Date: February 18, 2005 at 06:47:06 Pacific
Reply:

Hi 9ball
Will something like this help.

@echo off
for %%a in (*.zip) do echo d | xcopy %%a i:\Dir\%%a


0

Response Number 2
Name: 9ballninja
Date: February 18, 2005 at 13:27:32 Pacific
Reply:

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!


0

Response Number 3
Name: 9ballninja
Date: February 19, 2005 at 10:56:14 Pacific
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!)


0

Response Number 4
Name: jboy
Date: February 19, 2005 at 11:06:40 Pacific
Reply:

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.


0

Response Number 5
Name: 9ballninja
Date: February 19, 2005 at 13:48:09 Pacific
Reply:

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.


0

Related Posts

See More



Response Number 6
Name: dtech10
Date: February 19, 2005 at 15:08:56 Pacific
Reply:

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\%%a

or 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


0

Response Number 7
Name: dtech10
Date: February 19, 2005 at 15:12:28 Pacific
Reply:

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.



0

Response Number 8
Name: wizard-fred
Date: February 20, 2005 at 08:26:47 Pacific
Reply:

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.


0

Response Number 9
Name: 9ballninja
Date: February 22, 2005 at 16:49:45 Pacific
Reply:

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!


0

Response Number 10
Name: wizard-fred
Date: February 23, 2005 at 07:12:11 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: using pipe ( | ) with xcopy command

Problems running batch file with xcopy command www.computing.net/answers/dos/problems-running-batch-file-with-xcopy-command/5754.html

error with xcopy www.computing.net/answers/dos/error-with-xcopy/16067.html

xcopy command www.computing.net/answers/dos/xcopy-command/2306.html