[<<]Message[>>]    [<<]Author[>>]        Subject[>>]    [<<]Thread[>>]

Number : 81 Date : 2001-05-18 Author : Kan Yabumoto Subject : Re: /WD Quiz answer Size(KB) : 4
Let me repeat the question in the Quiz. What do you expect if there is no object (directory or file) named mydir in C:'s directory C:\mydir D\dest /I /S /E OK. I've been waiting for more answers. But, Jim's answer was so thorough, and right on the money, nobody had anything more to add. At 2001-05-17 18:18, you wrote: >Kan, I like your quiz! Let me see if I can give you the right answer. > > > XXCOPY C:\mydir D:\dest /I /S /E > >When XXCOPY does not find a directory named "mydir" in c:\, XXCOPY assumes >you intended to use "mydir" as the file template part of the source >specifier. Then it looks through all the directories in C:\, looking for >files named "mydir". There are no files named "mydir" anywhere in the >directory tree, so none are copied. But along the way, because the /E >switch was specified, all of the directories under C:\ are copied to >D:\dest - empty directories. > >Now, why are all those directories (which do not contain a file named >"mydir") considered to be "empty directories" -- which are therefore copied >because the /E switch was specified? I guess XXCOPY considers them to be >"empty" because they didn't contain any files matching the specified file >pattern ("mydir"), even though they may have contained other files. XCOPY >shows the same behavior. If the /E switch isn't used, no empty directories >are created under d:\dest - but XXCOPY still goes looking through all the >directories for files named "mydir" > >Putting a backslash after the source directory - > >xcopy c:\mydir\ d:\dest\ > >saves a lot of trouble. It specifies that you are looking for a directory >named mydir, not a file named mydir, and XXCOPY aborts quickly without doing >a futile search for files named "mydir". > >Is there any reason NOT to use a trailing backslash on the source and >destination directories? It seems like it would always be the safest thing >to do. Jim notices that when the source specifier was appended by a backslash, the source specifier will no longer be ambiguous whether it is a filename pattern or directory name. This is a very good point and indeed we have been advocating the use of trailing backslash for a directory name in the source specifier. The same goes to the destination specifier. Unlike the case of XCOPY, XXCOPY eliminated the file vs directory ambiguity for the destination specifier by not allowing it to be a file name. That is why XXCOPY will never issue the familiar user prompt of Does xxxxx specify a file name or directory name on the target (F = file, D = directory)? We eliminated this nonsense by not allowing the destination specifier to be a file. This is one of the very few cases where we deliberately chose to implement the behavior of XXCOPY different from that of Microsoft's XCOPY. We continue to believe this was a right design decision. As to the purpose of the trailing backslash on the destination specifier, with this "destination-as-directory-only" method, you may think the presence of the trailing backslash for the destination not significant. Well, that is not the case. While XXCOPY does not ask the familiar silly question in the prompt, it still ask your permission whether or not you intend to create the destination directory. So, in effect, XXCOPY replaced the silly prompt with a more reasonable prompt. Is this all? In our opinion, no. The prompt is still necessary because it may well be a case of mistyping of an existing directory. In either case (XCOPY or XXCOPY), you can suppress the prompt for the creation of the destination directory by the /I switch. The trailing backslash on the destination specifier serves as an implied /I switch. Therefore, we recommend the use of the trailing backslash on both the source specifier and the destination specifier. An alert reader will notice that this is reflected in the fact most of the XXCOPY command examples are written as consistent to this idea. Kan Yabumoto ========================================================================
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.