How to? @replace[a comma,_,filename]

Apr 2, 2011
1,441
10
54
North Carolina, USA
How can I replace a "," that is in a filename with a "_" ? Maybe escape the comma but not sure how to....
 
May 20, 2008
11,400
99
Syracuse, NY, USA
You could just rename the file. :-)
Code:
v:\> touch /c "a,b"
2017-05-17 00:53:43.424  V:\a,b

v:\> ren "a,b" a_b
V:\a,b -> V:\a_b
     1 file renamed

In any case, you'll have to rename it sooner or later. As you thought, escaping the comma in @replace works with little fuss.
Code:
v:\> do f in "a,*" (ren "%f" %@replace[^,,_,%f])
V:\a,b -> V:\a_b
     1 file renamed
v:\> do f in "a,*" (ren "%f" %@replace[^,,_,%f])
V:\a,b -> V:\a_b
1 file renamed
 
Oct 20, 2017
31
0
Netherlands
Thanks, works excellent: do f in "a,*" (ren "%f" %@replace[^,,_,%f])

At the end, I want to restore the original filename, renaming "_" with ","
Code:
do f in "a_*" (ren "%f" %@replace[_,^,,%f])
a_b -> V:\ab
Not the result I want. How to solve?

You could just rename the file. :-)
Code:
v:\> touch /c "a,b"
2017-05-17 00:53:43.424  V:\a,b

v:\> ren "a,b" a_b
V:\a,b -> V:\a_b
     1 file renamed

In any case, you'll have to rename it sooner or later. As you thought, escaping the comma in @replace works with little fuss.
Code:
v:\> do f in "a,*" (ren "%f" %@replace[^,,_,%f])
V:\a,b -> V:\a_b
     1 file renamed
v:\> do f in "a,*" (ren "%f" %@replace[^,,_,%f])
V:\a,b -> V:\a_b
1 file renamed
 
Similar threads
Thread starter Title Forum Replies Date
Joe Caverly Documentation Replace internal command with LIBRARY command Support 0
I how to make TCC default/replace cmd.exe? Support 9
x13 TPIPE /REPLACE - Remove line (including EOL) Support 3
T @replace -- what is wrong here Support 2
C Replace 1st argument on command line Support 4
R How to? Replace in Rename Support 9
MickeyF Can't get my TPIPE /replace to work Support 4
C @replace and @xreplace problems Support 5
C How to? Replace &'s in filenames / FixNames.dll Support 2
M I'm unable to use @replace[] with a % character in string2 Support 12
MikeBaas Strange prob with %@replace.. Support 4
vefatica Back-refs in TPIPE's /replace's replacement string? Support 2
Frank @replace works case sensitive Support 5
J @replace weirdness Support 1
vefatica TPIPE /replace? Support 3
Stefano Piccardi replace tcc process space? Support 8
vefatica @SUBST ... how replace character with a caret? Support 9
mdwyer @replace - global use in a text file Support 3
B Regex and Replace Support 6
B REPLACE is good news Support 0
J Problem with %var:find=replace% syntax Support 5
vefatica @INT with comma as decimal character Support 2
fpefpe comma in command line Support 0
M Is bash-like filename completion possible? Support 3
K Fixed Prompt display will be shifted after use dir to display a filename with Chinese. (v25.00.28 x64) Support 18
vefatica PDIR with fixed-width unqualified filename? Support 2
D When copying/moving, appending " (2)" to filename when the target file already exist. Support 7
gworley Virtual network drive filename completion doesn’t get directories Support 0
Joe Caverly CMD.EXE and filename(1).ext Support 3
D Exclude extension from filename completion Support 1
rfaquino How to? Display filename being copied on a single line Support 2
yjchung Filename completion broken?? Support 1
JohnQSmith Filename completion Support 8
S 16.00.41 - filename completion locks up TCC Support 14
R WAD issue with filename completion with system and hidden files Support 8
R How to? How to prevent filename completion for some file types? Support 3
M Filename completion with forward slashes Support 10
C How to? tell is @full[filename] contains any special JPSosft special chars Support 1
James Miller How to? filename completion question Support 1
J Fixed Filename completion does not quote filenames containing ^ Support 1
A How to? Filter a list by numeric number within filename Support 28
newbie Change percent-sign to anything-else in filename Support 24
Jay Sage Filename Completion in Take Command vs. TCC Support 1
J Filename Completion Window Support 1
vefatica Filename completion anomaly Support 2

Similar threads