Advertisement
jcunews

ListCJK.vbs

Feb 4th, 2019 (edited)
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'Lists files with CJK characters
  2. 'Usage e.g.: cscript listcjk.vbs "d:\my files"
  3.  
  4. set fs = createobject("scripting.filesystemobject")
  5.  
  6. function iscjk(fn)
  7.   dim i, c
  8.   iscjk = false
  9.   for i = 1 to len(fn)
  10.     c = ascw(mid(fn, i, 1))
  11.     if _
  12.       ((c >=  &H1100) and (c <=  &H11ff)) or _
  13.       ((c >=  &H2e80) and (c <=  &H2eff)) or _
  14.       ((c >=  &H2ff0) and (c <=  &H2fff)) or _
  15.       ((c >=  &H3000) and (c <=  &H318f)) or _
  16.       ((c >=  &H30a0) and (c <=  &H30ff)) or _
  17.       ((c >=  &H31a0) and (c <=  &H4dbf)) or _
  18.       ((c >=  &H4dc0) and (c <=  &H9fff)) or _
  19.       ((c >=  &Ha960) and (c <=  &Ha97f)) or _
  20.       ((c >=  &Hac00) and (c <=  &Hd7ff)) or _
  21.       ((c >=  &Hf900) and (c <=  &Hfaff)) or _
  22.       ((c >=  &Hfe30) and (c <=  &Hfe4f)) or _
  23.       ((c >= &H1b000) and (c <= &H1b0ff)) or _
  24.       ((c >= &H1f200) and (c <= &H1f2ff)) or _
  25.       ((c >= &H20000) and (c <= &H2a6df)) or _
  26.       ((c >= &H2a700) and (c <= &H2b81f)) or _
  27.       ((c >= &H2f800) and (c <= &H2fa1f)) then
  28.       iscjk = true
  29.       exit for
  30.     end if
  31.   next
  32. end function
  33.  
  34. sub list(path)
  35.   dim dir, file, s, subdir
  36.   set dir = fs.getfolder(path)
  37.   s = dir.path
  38.   if right(s, 1) <> "\" then s = s & "\"
  39.   for each file in dir.files
  40.     if iscjk(file.name) then wsh.echo s & file.name
  41.   next
  42.   for each subdir in dir.subfolders
  43.     list s & subdir.name
  44.   next
  45. end sub
  46.  
  47. if wsh.arguments.count = 0 then
  48.   wsh.echo "Usage: listcjk {path}"
  49.   wsh.quit 1
  50. end if
  51. if not fs.folderexists(wsh.arguments(0)) then
  52.   wsh.echo "Path is not found or invalid."
  53.   wsh.quit 2
  54. end if
  55. list wsh.arguments(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement