By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!c:\users\vefatica\desktop\test1> do x in /a:d * ( echo %@ascii[%x] )
84 101 115 116 50 32 11088 65039
84 101 115 116 51 32 11088 65039
119 97 115 116 101 115 116 49
c:\users\vefatica\desktop\test1> ren "Test2 %@char[11088]%@char[65039]" Test2
C:\Users\vefatica\Desktop\test1\Test2 ⭐️ -> C:\Users\vefatica\Desktop\test1\Test2
1 dir renamed
c:\users\vefatica\desktop\test1> d
2022-05-08 17:32 <DIR> Test2
2022-05-08 17:10 <DIR> Test3 ⭐️
2022-06-02 16:48 <DIR> wastest1
2022-06-02 18:46 1,244 file.txt
2022-06-02 16:34 33 list.txt
2022-06-02 16:51 522 uni2.txt
2022-06-02 16:35 457 unicode.txt
I wanted the directory names truncated, extraneous junk on the end removed, but I couldn't seem to make fixnames do that, he wanted to substitute, not trim. I asked for blanks, he gave me underscores, so the directory names ended with " __" (one blank, two underscores).
function fix=`%@replace[%@char[0x20 0x2b50 0xfe0f],,%@name[%1]]`
ren /a:d /s /n * `%@fix[*]`
I'm getting unexpected results from your code. It truncates the directory name at the first occurrence of a blank. It works for the test case I gave (above), but if you have any directory names with embedded blanks, it goes south.Yeah, that whole /Q /R thing is pretty simpleminded. It always just replaces one character with one characters. I could probably work up some kind of syntax to delete characters. But that command is already overly ornate for its original purpose: fixing filenames containing percent signs (and a couple other characters troublesome for TCC).
Here's a different approach. A user-defined function to strip the offending characters out of a filename:
Code:function fix=`%@replace[%@char[0x20 0x2b50 0xfe0f],,%@name[%1]]`
And using that function in REN via delayed expansion:
Code:ren /a:d /s /n * `%@fix[*]`
I'm getting unexpected results from your code. It truncates the directory name at the first occurrence of a blank. It works for the test case I gave (above), but if you have any directory names with embedded blanks, it goes south.
Given a directory "xx yy zz", it would truncate to "xx".
function fix=`%@replace[%@char[0x20 0x2b50 0xfe0f],,%@name[%$]]`
ren /a:d /s /n * "%%@fix[*]"