I asked because I use xcopy to backup my data folders every day and I don't use a dot.
e.g.
C:\>xcopy "C:\Program Files\Lyceum" "S:\Backup\Lyceum"
I don't doubt it!
Notice that in my first post, I told NCwill that code similar to yours also works for me:
First, you don't want both /E & /S
/E will do it all!
The following code works for me in Windows XP. (My Flash drive is L:)
xcopy "C:\Flash_Copy\temp" L: /E
I commented that:
In the past in other versions of DOS/Windows, I have had trouble with Xcopy being very very picky.
&
It is not always necessary to give dos a full path, but it never hurts.
&
Dos will sometimes assume what you want as it did on this line. Other times the full path is required, as I believe it may be on the problem line.
I stand behind those statements!
For example, if you are not specific enough, as in the following:
C:\>xcopy /E "C:\Machine Tool Company" "L:\Machine Tool Company"
xcopy gets confused and asks you:
Does L:\Machine Tool Company specify a file name
or directory name on the target
(F = file, D = directory)?
Is xcopy really so stupid that it does not know that what you want is to duplicate the "Machine Tool Company" folder from the C: drive to the L: drive? No. The problem is that I was not specific enough.
The problem can be corrected several ways but the answer lies in being more specific.
Both of the following(and probably other ways) will create the destination folder (and copy the files) that you wanted:
xcopy /E "C:\Machine Tool Company\*.*" "L:\Machine Tool Company\*.*"
xcopy /E "C:\Machine Tool Company" "L:\Machine Tool Company\*.*"
In NCwill's case, there was another problem involved. Due to the fact that the target disk had been "freshly" formatted, Windows /DOS had temporarily lost contact with the disk. That can be seen by this test. Open a copy of Explorer to the flash drive. Run the batch file. At the completion of the format, that copy of explorer is closed. I'm not sure of the technical reason for this behavior, but I ASSume that dos is programed to reinitialize the disk at that time. Whatever the exact reason, the fact that the disk has been "freshly" formatted, throws a curve at the following xcopy command. I tested numerous variations and found that many possible command lines worked if a format was NOT involved. The next example uses code nearly identical to the code Dias suggested. It does not work when a format is involved, but works fine without the format.
The following three lines
WILL ALL work on a disk that was
NOT "freshly" formatted.
But ... WILL
NOT work on a disk that
WAS "freshly" formatted.
xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:
xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:\.
xcopy /E "C:\Flash_Copy\temp" %DriveLetter%:\*.*
The following three lines
WILL ALL work on a disk that
WAS "freshly" formatted.
xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:
xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\.
xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\*.*
The following line is the BEST CHOICE. It is the
MOST COMPLETE in the eye's of "DOS"
xcopy /E "C:\Flash_Copy\temp\*.*" %DriveLetter%:\*.*
Part of the problem here lies in the format command being used here,
But a big part of the problem lies in the fact that we are lazy.
copy *.* A:
works fine because dos is programmed to ASSume that you mean copy all files in the current directory since you did not specify the source directory. It also assumes that you meant the root of A: as your destination.
BUT ... If you tried to use copy to create a folder on a named temp:
copy *.* A:\temp
Copy is not able to create folders, so dos ASSumes that you wanted to copy all the files in the current directory to a new file on the root of A:
Even though there were several files to copy, dos returns with:
1 file(s) copied.
Why "1 file"?
DOS wrote one new file named temp and copied the contents of all the files into the one. It ASSumed that was what you wanted.
Which brings us back around to my point that:
It,s best not to ASSume that DOS will be able to figure out exactly what you want to do.
It is always better to give dos the full path, even though many times it may work without it.
We all know what ASSuming does, but since we all tend to be a little lazy we tend to give dos just enough of the path to get by.
Sometimes, as in this case, being lazy might just bite us all in the ... you know where!
PS: A few weeks(or months) back there was another formatting/backup problem that we resolved for the fellow with the RD command and the use of the \.(DOT) to represent the root directory for the RD command that required a directory name be specified(*.* did not work). I guessed (wrongly in this case) that xcopy was looking for a directory name in NCwill's xcopy command.
I would hazard a guess that the problem a few weeks back could have been the same as NCwill's. If so, this solution would have been better all the way around.