Filenames with semicolons

Jan 19, 2011
604
14
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
604
14
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
604
14
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
Thread starter Title Forum Replies Date
Phileosophos PDIR to list filenames without extensions? Support 2
D How to? Filenames with "&" character Support 3
fpefpe How to? processing filenames Support 6
C Filenames with ";" Support 13
E Fixed DEDUPE doesn't handle filenames with whitespace properly when symlinking Support 1
mikea How to? Problem with @SFN (short filenames) Support 6
A CDD and DOS filenames Support 1
A How to? Work with Filenames Containing Brackets "[" and "]" Support 2
C How to? Replace &'s in filenames / FixNames.dll Support 2
BobK How to? Handling filenames with blanks at command line Support 3
J Fixed Filename completion does not quote filenames containing ^ Support 1
T Square brackets in filenames Support 1
P Support for national letters in filenames in ftp operations Support 1
N Problems with backquotes in filenames Support 17
S Suggestion: enhanced automatic quoting of filenames Support 2
S PDIR has trouble processing filenames with embedded percent sign Support 3
C handling percent signs in filenames Support 2
C handling percent signs in filenames Support 1
B Problems with %-sign in filenames/directory names Support 6
Jay Sage Dealing With Filenames Containing Slash Character Support 5
A Color in filenames in listview Support 1

Similar threads