这个问题同样也困扰了许多人啊,试试这个吧- set "p=C:\1\2"
- rem 以上设置目录
- powershell -c "$i = 1;$files = dir -LiteralPath '%p%' -File ;Add-Type 'using System;using System.Collections.Generic;using System.Runtime.InteropServices;public static class ExpDir{[DllImport(\"Shlwapi.dll\",CharSet=CharSet.Unicode)]public static extern int StrCmpLogicalW(string p1,string p2);public static string[] Sort(string[] f){Array.Sort(f,StrCmpLogicalW);return f;}}';[ExpDir]::Sort($files) | %%{ren ('%p%\' + $_) -NewName ('{0:D3}{1}' -f $i, $([IO.Path]::GetExtension($_))); $i ++}"
复制代码
|