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

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#2
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
2
0
#4
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