連番を付けてリネーム

UWSCでリネームも出来ます。すごいっ!
VBscriptでも出来ますが、ファイル名順でする術を知らないんです。
shell.applicationのnamespaceだと、ファイル名順で出来ない。
んー、出来る方法があるのかな?


で、↓は指定したフォルダに入っているファイルを、フォルダの名前+連番でリネーム。

dpath = input("ディレクトリのパスを入力")
  if dpath = empty then exit
  ifb fopen(dpath + "\", f_exists)// フォルダが存在したらリネームを開始
    sfo = createoleobj("scripting.filesystemobject")
    foldername = betweenstr(dpath + "/", "\", "/", - 1)// フォルダの名前
    for i = 0 to getdir(dpath) - 1
      ex = sfo.getextensionname(getdir_files[i])// ファイルの拡張子
        if length(ex) > 0 then ex = "." + ex else ex = ""// 拡張子がない場合は""
      num = chgmoj(format(i + 1, 3), " ", "0")// 連番は3桁
      sfo.movefile(dpath + "\" + getdir_files[i], dpath + "\" + foldername + num + ex)// リネーム
    next
  endif