From the computer of: seamonkey420
(130 recipes)
Created: Nov 07, 2007 Updated: Nov 08, 2007
XCOPY is a command that is present in XP's command prompt.
XCOPY allows one to copy both files and directories in one command vs copying a folder or files in a folder one at a time using the COPY command. COPY does not allow you to copy subdirectories w/the *.*
Here is an example of when would use XCOPY vs COPY:
I have a folder on my C: drive called DATA
and under this folder i have a ton of text files (.txt) and also 3 folders called 1 2 and 3 which also have .txt files in them.
However, in the folders there are files with the name SECRET on them that i do not want copied.
I want to then copy this data w/the folder structure intact to a folder called BKUP on my C: drive.
Here is how we would use XCOPY and the /EXCLUDE tag to do this:
1. either open command prompt up or create new text file (if you plan to make .bat file). we will do a new text file and in turn make it into a batch file. after we create the new text file, rename it to test.bat for now.
2. right click the test.bat file and choose to Edit or Open With > Notepad.
3. we will add this command (i will explain each flag used)
XCOPY C:\DATA\*.* C:\BKUP /S /I /Y /EXCLUDE:c:\excludelist.txt
the /S flag = copies all directories and subdirectories except empty ones (use the /E instead if you want empty folders also copied)
the /I flag = If the destination does not exist and we are copying more than one file, it will assume the destination is a folder
the /Y flag = Suppresses all prompts to overwrite destination file if it already exists
the /EXCLUDE flag = this will point to a file that has the excluded file types or folder or file names. in my example, i created a text file called: excludelist.txt in the root of my C: drive.
in that excludelist.txt, i then added the word SECRET on the first line. If you have more than one excluded item; be sure to put each on a new line.
So once i run this batch file, it will look at the excludelist.txt file and then exclude any thing that contains the terms i put in the file from being copied (so none of my files w/SECRET in the name will be copied).
The main thing to remember when using the /EXCLUDE flag is that you have to put the location of the excluded file list after the flag; not the actual excluded items/terms. That initially was the most confusing part. You can create multiple excluded file lists; you would need to use the + list (ie XCOPY c:\* v:\ /EXCLUDE:c:\excluded1.txt+c:\excluded2.txt )
Subscribe to the Tech-Recipes Newsletter
You can get tips like this delivered in your email every week!
We will never, ever sell your email address or spam you.
Related recipes:
Processing the contents of a text file using FOR loop
Using variables in Windows batch files
XP batch files: Create variable for current user account and find current user
Batch Files : Get users default printer via registry (WinXP)
Supress Responses From Commands In Batch Files
Windows XP/Vista: Use a Batch File for Quickly Restarting explorer.exe
XP Batch Files: Copy images from camera to pc and organize by date
Batch File Converting of Video Files: SageTV example
Supressing Prompts In Batch Files While Deleting All Files
Create Batch File to Start or End Window Services
Sponsored links
Login
Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.Search
Tech Recipes
· Home
· Mac OS X
· Solaris
· Windows
· Programming
· UNIX
· Cisco
· MySQL
· Google
· Instant messaging
· Add recipes
· Leave feedback
· Recommend us
· RSS Syndication
Hot recipes
Make XP look like Windows Vista / Longhorn for free!
XP: Small, Free Way to Use and Mount Images (ISO files) Without Burning Them
How Do I Use or Open Bin, Cue, or ISO Files?
Vista: Should I Install 64-bit or 32-bit Version? (x64 vs x86)
Hacks to Beat Rapidshare Download Limits and Waiting Time
MySpace Hack: View Pictures and Comments on a Private Profile
SMS through E-Mail: Cingular, Nextel, Sprint, T-Mobile, Verizon, Virgin Mobile
MySpace: Hack to Download Any Song on MySpace
Who's Online
There are currently, 2160 guest(s) and 2 member(s) that are online.
You are Anonymous user. You can register for free by clicking here
Information
Wish to advertise with us?
All logos and trademarks in this site are property of their respective owner. The comments and forum posts are property of their posters, all the rest © 2003-2007 by QD Ideas, LLC.
Users of this site are legally bound by the Terms and conditions and Disclaimer. Do not use this web site if you do not agree with these policies.
The members, admins, and authors of this website respect your privacy.
Page Generation: 0.82 Seconds
Sun Jul 20 15:09:01 2008