Filenames with ";"

Apr 2, 2011
1,607
15
55
North Carolina, USA
I want to replace filenames that contain ";" with "_". I can't even get plain DIR to find the files.

Code:
for %fn in ("*;*") ren "%fn" "%@replace[;,_,%fn]"

dir /a:-d /b /s "*;*"

Both do not work.

@vince - would this be a good char to have your fixnames plugin to work on?
 
Dec 7, 2009
238
2
Left Coast, USA
I want to replace filenames that contain ";" with "_". I can't even get plain DIR to find the files.

Code:
for %fn in ("*;*") ren "%fn" "%@replace[;,_,%fn]"

dir /a:-d /b /s "*;*"

Both do not work.

Interesting. Both of the above work for me (under TCC 20.00.14 x64 — Windows 10 Pro). The renaming worked fine:

D:\temp> for %fn in ("*;*") ren "%fn" "%@replace[;,_,%fn]"
D:\temp\test2;hello.txt -> D:\temp\test2_hello.txt
1 file renamed
D:\temp\test3;goodbye.txt -> D:\temp\test3_goodbye.txt
1 file renamed
 
May 20, 2008
12,167
133
Syracuse, NY, USA
It doesn't seem much different from the comma (except that I couldn't make one with TOUCH).
Code:
v:\> echo foo > "a;b.txt"

v:\> d "*;*"
2017-05-17  12:11               5  a;b.txt

v:\> do f in "*;*" (ren "%f" %@replace[;,_,%f])
V:\a;b.txt -> V:\a_b.txt
     1 file renamed
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,689
106
Albuquerque, NM
prospero.unm.edu
Suggestion for a future version: Allow the vertical bar | as an include-list separator, behaving just the same as the semicolon. Then in some more-distant-future version, the semicolon could be deprecated.... Filespecs containing a vbar would need to be quoted, of course, just like spaces, ampersands, et cetera.

(The choice of semicolon for this function goes back to 4DOS. IIRC, semicolon was not a legal filename character in DOS, so it made sense at the time.)
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
4,689
106
Albuquerque, NM
prospero.unm.edu
And what would we do with pipes? And a jillion batch files and aliases using pipes?

You already have that part implemented. A vertical bar between quotes has no special meaning.

Code:
C:\>dir "*.bat|*.cmd|*.btm"

 Volume in drive C is Hard Drive     Serial number is 6218:b594
TCC: (Sys) The system cannot find the file specified.
 "C:\*.bat|*.cmd|*.btm"
                   0 bytes in 0 files and 0 dirs
     156,308,537,344 bytes free

C:\>
 
May 20, 2008
12,167
133
Syracuse, NY, USA
Not sure what you're getting at -- a semicolon between quotes has no special meaning either.
Is that so? Why did my first attempt to create "a;b" fail?
Code:
v:\> touch /c "a;b"
2017-05-17 20:28:38.034  V:\b
And there seems to be a special meaning here also.
Code:
v:\> *dir /a /p /m /k /h /ne "a;b"
2017-05-17  20:28               0  b
 
May 20, 2008
12,167
133
Syracuse, NY, USA
What's going on with TOUCH? Below, it created only "b".
Code:
v:\> touch /c "a;b;c"
2017-05-17 21:52:14.842  V:\b
 
May 20, 2008
12,167
133
Syracuse, NY, USA
What's going on with TOUCH? Below, it created only "b".
Code:
v:\> touch /c "a;b;c"
2017-05-17 21:52:14.842  V:\b
I didn't quite have that figured out. Using TOUCH /C "a;b;c", if any exist it'll touch (only) them; in none exist, it'll create only the last one specified.
 

Similar threads