![]()
[<<]Message[>>] [<<]Author[>>] Subject [<<]Thread
Number : 2809 Date : 2002-09-16 Author : Kan Yabumoto Subject : The Trailing Backslash Size(KB) : 5
This message is in response to Brian's question. He had an interesting case. It boils down to the following questions: What is the difference between the following two? xxcopy \abc\xyz \dst xxcopy \abc\xyz\ \dst To add some complexity to it, what about the following cases? xxcopy \abc\*\xyz \dst xxcopy \abc\*\xyz\ \dst In Brian's case, the base directory (the longest path in the source specifier without wildcards) happens to be the root directory. But, the same rules apply and therefore, I will use the more general case with a non-root directory. The trouble is that there is a subtle syntactic ambiguity which XXCOPY inherited from Microsoft's XCOPY in the source specifier. As long as XXCOPY continues to adhere to the XCOPY-compatible syntax, we all have to live with this nuisance. That is, the source specifier often has this ambiguity between a directory name and a filename pattern. When you say xxcopy \abc\xyz \dst The lastname, xyz can be interpreted either as a file name or a directory name. In this case, the only way to tell them apart is by examining the contents of the parent directory (\abc\ in this case) and see whether the lastname item exists as a directory. If so, it will be interpreted as a directory (i.e., equivalent to \abc\xyz\*). If the item is not a directory, it will be treated as a filename. That is how XCOPY behaves and also how XXCOPY does. Fortunately, there is a way to resolve this ambiguity --- add a trailing backslash whenever you mean the lastname to be a directory name. By rewriting the command (with a trailing backslash), xxcopy \abc\xyz\ \dst there is no longer the ambiguity. This command line will be interpreted in only one way: xxcopy \abc\xyz\* \dst Now, with the wild-wildcard scheme, the rule is even further from what Brian intended. xxcopy \abc\*\xyz will be interpreted only in one way. That is, if you insert a wildcard character anywhere other than the lastname portion, the lastname which does not have a terminating backslash will be interpreted as a filename, and never a directory name. In this case, this command line does not even test whether or not the lastname item is present as a directory. It is always interpreted as a filename specifier. So, Brian's problem should go away by rewriting his command line with the backslash at the end of the source specifier. xxcopy "e:\(exact-pathname_here)\normal.dot\" d:\ xxcopy e:\*\normal.dot\ d:\ The two are similar (but of course, not the same because the second line could match more than one directories that may exist in the entire volume of E:). My advice to all users is that you should form a habit of placing the trailing backslash whenever you mean a directory name (even though the syntax allows you to be sloppy and omit the trailing backslash --- a common source of mysterious behaviors). The same advice can be applied to the destination. I always put a trailing backslash in the destination. Since XXCOPY does not accept any filename specifier in the destination (a deliberate departure from XCOPY-compatibility), the trailing backslash in destination has a different meaning. The trailing backslash in destination specifier implicitly adds the /I switch (which suppresses the prompt for creating the new destination directory when it is absent and creates the destination directory unconditionally) . In almost all cases, this is what we want. So, to reinforce the good habit of adding the trailing backslash in *ALL* directory name, I advocate the use of trailing backslash in both the source and the destination specifiers. * * * * * * * * * * * * * * * * * Let me summarize equivalent cases below: Note: the equivalence of the /S switch is a little different for a filename and for a directory name \abc\*\xyz // this is equivalent to the following \abc\xyz /S \abc\*\xyz\ /S0 // without /S, it is equivalent to: \abc\*\xyz\* // 1st-level files \abc\*\xyz\ /S // with /S, it is equivalent to \abc\*\xyz\*\* // files in all levels The following two are different unless you have /S \abc\*\xyz\* \abc\*\xyz\*\* Note: if you are a very experienced user who uses the exclusion specifiers a lot (/X), make sure the different meaning of a trailing backslash. In the source specifier, \abc\xyz\ // equivalent to the following \abc\xyz\* // only 1st-level files unless you have /S In the exclusion specifier, /X\abc\xyz\ // equivalent to the following /X\abc\xyz\*\* // 1st-level and also subdirectories Sorry for the confusing issues here. But, to effectively use XXCOPY, advanced users need to understand these cases (which can be derived from our documentations, albeit, they are not straightforward). Have a nice day. Kan Yabumoto ============================================================= At 2002-09-16 01:45, you wrote: >The file "e:\documents and settings\brian phillips\application >data\microsoft\templates\normal.dot" is where MS Word stores some of its >preferences. If I attempt to copy this file using - > >xxcopy "e:\ . . . \normal.dot" d:\ (specifying the full path) > >then copying proceeds correctly. However, if I use - > >xxcopy e:\*\normal.dot d:\ > >then no files are found to copy. > >Any sugestions as to where I am going wrong would be appreciated. > >Brian
This message if part of XXCOPY's message Archive. The archive contains all the messages posted at Yahoo!Groups: XXCOPY.