Filenames with semicolons

Jan 19, 2011
614
15
Norman, OK
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
 
Jan 19, 2011
614
15
Norman, OK
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.
 
Jan 19, 2011
614
15
Norman, OK
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