Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: question - batch file only works with "unofficial" directory name

01 Jan 2013   #1
rcrgs

Win7 professional 64bit
 
 
question - batch file only works with "unofficial" directory name

Hello...
I'm using a command line batch file to backup files from my W7 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 W7 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.
...robert


My System SpecsSystem Spec
.
01 Jan 2013   #2
Brink

64-bit Windows 10 Pro
 
 

Hello Robert,

"My Documents" is just a symbolic link to "Documents" for backwards compatibility for older programs that still reference "My Documents". "Documents" is the true folders name. It's the same with all of the "My...." user folders.

Hope this helps,
Shawn
My System SpecsSystem Spec
01 Jan 2013   #3
Kari

Microsoft Community Contributor Award Recipient

 

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:
Code:
"xcopy c:\users\your_username\my documents\*.*" "D:\Docs"
This would produce an error message as seen here:

question - batch file only works with "unofficial" directory name-path_quotes_1.png

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:
Code:
xcopy "c:\users\your_username\my documents" D:\Docs
Also notice that wildcards *.* are useless with XCOPY command. XCOPY always copies all files of the folder.

With this small change the content of the folder My Documents would be copied:

question - batch file only works with "unofficial" directory name-path_quotes_2.png

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:

question - batch file only works with "unofficial" directory name-path_quotes_3.png

Sorry the rant, an old school geek just loves to speak about command line language .

Kari


My System SpecsSystem Spec
.

01 Jan 2013   #4
Brink

64-bit Windows 10 Pro
 
 

Quote   Quote: Originally Posted by Kari View Post
Sorry the rant, an old school geek just loves to speak about command line language .

Kari
My System SpecsSystem Spec
05 Jan 2013   #5
rcrgs

Win7 professional 64bit
 
 

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.
...robert
My System SpecsSystem Spec
05 Jan 2013   #6
Kari

Microsoft Community Contributor Award Recipient

 

You are welcome, Robert.
My System SpecsSystem Spec
Reply

 question - batch file only works with "unofficial" directory name




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
Defrag.exe won't run from a batch file. "Insufficient permission."
I want to defrag my C and E drives before Norton Ghost backs them up. Norton Ghost will run a batch file before the backup, so I made a simple one: C:\Windows\System32\Defrag.exe C: E: It won't run, however. I get an error message saying I have "insufficient permission" to run...
General Discussion
Need a Batch file or similar for "detect display" in display settings.
Hi, I need a batch or similar type file that will "detect display" from (Control Panel\All Control Panel Items\Display\Screen Resolution). HP dv6 use switchable graphics and they can be seriouly problematic to update. Anyway the only way i can use the latest driver is if i put up with aero...
Performance & Maintenance
Batch file only works in certain directory
I made a batch file that says this: @echo off cd C:\Users\John\Desktop rename ring.gif ring.jpeg The actual batch file is saved on my I:\ drive, not my C:\ drive. My I:\ drive is an internal HDD that is able to talk with my C:\ drive. When I execute the .bat file, it does nothing...
General Discussion
Default "Browse for file" location in web browser "choose file" box
Hi, how can I change this? Some background - this may not be the issue I need to solve at the end of the day: I believe the location is causing crashes, since I blew up lots of Library registry values (in an attempt to remove them from the OS), and I think it defaults to the library page....
Customization
Need To Add "Authenticated Users" Every Directory Within "Music"
First off this is my work laptop. I have my standard Music library, which is a directory directly off the C drive. When I download or move into that "Music" directory the directory I moved has a lock icon on it. In order to get rid of the icon, I need to add "Authenticated Users" to the...
General Discussion
Done with "Unofficial" Builds
Howdy Y'all I've decided that all these Unofficial releases are just not worth the trouble anymore, and I'm going to concentrate on this Official RC release until we go RTM or another official release from MS. I have specific reasons for this also, the very foremost is that MS doesn't take...
General Discussion


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 10:34.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App