Home > OS >  Bat batch does not perform a folder within the file
Bat batch does not perform a folder within the file

Time:09-25

The code is the folder TXT file name in Chinese character digital replaced with Arabic numerals, the code is as follows, but the current folder can perform, subfolders within TXT not replace

1> 1/* : www.bathome.net

@ echo off

For/f "delims=" % % a in (' dir/a - d/b *. TXT ^ | cscript nologo - e: jscript "% ~ 0" ') do (

Ren % % a

)

Pause & amp; The exit/b

*/

Var files=WSH. StdIn. ReadAll (). The split (/\ r?
\ n/a)
For (var I in files) {

Var newName=files [I]. Replace (

01234567890 [O]/[01234567890] */gm,

Function (match) {

Var STR=match

STR=STR. Replace ([123456789]/g, function (match) {return '+' + 'empty the 123456789'. The search (match)})

STR=STR. Replace (/(1-9] [)/g ([1000]), function (match, _1, _2) {return _1 + ({' ten ':' * 10 ', 'best', '100', 'thousands' :' * 1000} [_2])})

STR=STR. Replace (10//^ '+ 10)

STR=STR. Replace (/(\ * 10 +) 0 [zero O] (? ! \ \ d + \ 1)/g, '$10)

Return (/[^ 0-9 \ + \ *]/. The test (STR))? Match: eval (0 + STR)

}

)

The WSH. Echo (' "' + files [I] + '" "' + newName + '"')

}

CodePudding user response:

This code is very good
  • Related