Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Filenames with semicolons

Jan
616
15
I am working with files that come from a VMS system.
HTML:
Z:\>dir
 Volume in drive Z has no label.
 Volume Serial Number is 58B8-A853
 
 Directory of Z:\
 
05/25/2012  12:25    <DIR>          .
05/25/2012  12:25    <DIR>          ..
05/17/2012  18:30               110 b1751830.053;1
05/17/2012  18:32               110 b1751832.043;1
05/17/2012  18:38               110 b1751838.015;1
05/17/2012  18:39               110 b1751839.010;1
 
>8------------------ SNIP ----------------------8<
 
05/18/2012  17:47           181,045 r1851747.067;1
05/18/2012  17:48           186,392 r1851748.074;1
05/18/2012  17:53           187,569 r1851753.009;1
05/18/2012  17:54           196,608 r1851754.037;1
05/18/2012  17:57           186,647 r1851757.039;1
             757 File(s)    138,743,731 bytes
               2 Dir(s)  26,210,402,304 bytes free
The number following the semicolon is used by the OS to represent the version number of the file.

In CMD, I get the following...
Code:
Z:\>ver
 
Microsoft Windows XP [Version 5.1.2600]
 
Z:\>dir /b | wc -l
757
 
Z:\>dir /b "*;1" | wc -l
755
 
Z:\>dir /b "*;2" | wc -l
2
 
Z:\>dir /b "*;3" | wc -l
File Not Found
0
In TCC, I get the following...
Code:
[Z:\]
10:45:41 $ ver
 
TCC  13.04.63   Windows XP [Version 5.1.2600]
 
[Z:\]
10:45:43 $ dir /b | wc -l
757
 
[Z:\]
10:46:01 $ dir /b "*;1" | wc -l
755
 
[Z:\]
10:46:09 $ dir /b "*;2" | wc -l
2
 
[Z:\]
10:46:12 $ dir /b "*;3" | wc -l
757
 
Remember that the semicolon is the include-list separator. If you want to match a literal semicolon in filenames, put it in square brackets:

Code:
dir /b "*[;]1"
 
Remember that the semicolon is the include-list separator. If you want to match a literal semicolon in filenames, put it in square brackets:

Code:
dir /b "*[;]1"

Thanks, although that doesn't explain why it works correctly when files exist that match and not when files are missing.
 
Thanks, although that doesn't explain why it works correctly when files exist that match and not when files are missing.

Perhaps semicolons are handled like square brackets are. The code may check for an exact match first, and then, only if there is no exact match, treats it as a wildcard.
 
What if you escape the semicolon?
Code:
dir /b "*^;1" | wc -l
Inside quotes, it gives an error.
Code:
[Z:\]
13:36:35 $ dir /b "*^;1" | wc -l
TCC: (Sys) The system cannot find the file specified.
 "Z:\*^;1"
0
Outside quotes, it gives the same results as TCC in post #1 above.
Code:
[Z:\]
13:38:47 $ dir /b *^;3 | wc -l
757
 

Similar threads

Back
Top