|01 Jan 2013||#1|
| || |
question - batch file only works with "unofficial" directory name
I'm using a command line batch file to backup files from my Windows 7 Pro x64 machine to an external USB HD. Basically, "xcopy c:\......\my documents\*.*" "external HD". I couldn't get this to work until I truncated the source directory to "documents" instead of "my documents" [the name that the Windows 7 installer specified]. While the batch file now runs and does what it's suppose to do, I'm mystified as to why the source directory needs to have a truncated name in the batch file rather that the one it has "officially." Any insight into this is appreciated.
|My System Specs|| |
|01 Jan 2013||#3|
| || |
In addition to what Brink told you above, in case you need to use batch files or command line also in the future: you seem to have a syntax error in your XCOPY command syntax.
If no folders and files on path have spaces, you do not need quotation marks ("). However, if a folder or file has space(s) on its name, the whole path must be between quotation marks. Important is that quotation marks when used come at the beginning and the end of the path, not at the beginning of the command line.
Your quotation marks, at least on your post above, are wrong. Let's say you really had a folder called My Documents on C:\Users\Your_Username\My Documents, and you would like to copy it to D: drive on folder called Docs. According to your post you would give that command as:
"xcopy c:\users\your_username\my documents\*.*" "D:\Docs"
But with correct usage of quotation marks the files would be copied. Here's the correct syntax, please notice the begin quotation mark just before the source path, not at the beginning of the command line, and the end quotation mark just after the source path. Destination path in this example of mine does not need quotation marks because it does not contain spaces:
xcopy "c:\users\your_username\my documents" D:\Docs
With this small change the content of the folder My Documents would be copied:
If you also want to copy subfolders and files on them you need to add handle /s, and if you want even to copy empty subfolders you need to add handle /e to the command line:
Sorry the rant, an old school geek just loves to speak about command line language .
|My System Specs|
|05 Jan 2013||#5|
| || |
Brink and Kari...
Thanks for your comments and help. Most useful. Asking folks about command prompt issues is always a good way of telling when they got into the game. I'm glad that MS keeps them available. One can do a lot of things from "C:\" in a simpler manner than by using higher level programs. Happy New Year.
|My System Specs|
|Similar help and support threads for: question - batch file only works with "unofficial" directory name|
|Default "Browse for file" location in web browser "choose file" box||Customization|
|Need To Add "Authenticated Users" Every Directory Within "Music"||General Discussion|
|Win7 "workstation" to WinXP "server" file copy FAIL||Network & Sharing|
|TIFF file LZW "batch" compression utility needed.||Software|
|Done with "Unofficial" Builds||General Discussion|