level 1
不清楚你的实际文件/情况,仅以问题中的样例说明及猜测为据;以下代码复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件夹放一起双击运行
<# :
cls&echo off&cd /d "%~dp0"&mode con lines=5000
rem 将当前目录里的多个子文件夹根据名称末尾的数字按照指定大小范围剪切/移动/归类到不同文件夹里
set #=Any question&set _=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
set "current=%cd%"
powershell -NoProfile -ExecutionPolicy bypass "Get-Content -literal '%~f0'|Out-String|Invoke-Expression"
echo;%#% +%$%%$%/%_% %z%
pause
exit
#>
$codes=@'
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;
}
}
'@;
Add-Type -TypeDefinition $codes;
$b=[Convert]::FromBase64String("IC0tPiA=");
$c=[Text.Encoding]::Default.GetString($b);
$scope=100000;
$current=$env:current;
$folders=@(dir -literal $current|?{($_.Name -match '^uid_') -and ($_ -is [System.IO.DirectoryInfo])}|%{$_.Name});
if($folders.length -ge 1){
$arr=[ExpDir]::Sort($folders);
for($i=0;$i -lt $arr.count;$i++){
$m=[regex]::match($arr[$i], '\d+$');
if($m.Success){
$n=[Math]::Ceiling([int64]$m.groups[0].value/$scope)*$scope;
$newfolder=$n.ToString();
if(-not (test-path -literal $newfolder)){[void][IO.Directory]::CreateDirectory($newfolder);}
$arr[$i]+$c+$newfolder;
}
}
}
2022年06月02日 17点06分

