杂乱无章的多个文件夹批量添加序号 有谁会的 能否发个代码给我呢
bat吧
全部回复
仅看楼主
level 1


2019年09月07日 15点09分 1
level 1
楼主,怎么不能用啊,麻烦你把源文件发我一份吧,q1094897402
2020年02月29日 13点02分 2
level 9
不清楚你的实际文件/情况,仅以问题中的样例/说明为据
复制粘贴到记事本,另存为xx.bat,编码选ANSI,跟要处理的文件夹放一起运行
<# :
cls
@璐村惂鐢ㄦ埛_000076K馃惥 off
rem 在多个子文件夹名称开头前面插入/添加数字序号
set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
title %#% +%$%%$%/%@璐村惂鐢ㄦ埛_053Q95e馃惥 %z%
set "rootpath=%~dp0"
if "%rootpath:~-1%" equ "\" (set "rootpath=%rootpath:~,-1%")
cd /d "%rootpath%"
powershell -NoProfile -ExecutionPolicy bypass "Invoke-Command -ScriptBlock ([ScriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%rootpath%'"
echo;%#% +%$%%$%/%@% %z%
pause
exit
#>
$isfile=$false;
$addzero=$true;
$first=1;
$path=$args[0];
$arr=@(dir -liter $path|?{$_ -is [System.IO.DirectoryInfo]}|%{$_.Name});
if($isfile){$arr=@(dir -liter $path|?{('.bat' -ne $_.Extension) -and ($_ -is [System.IO.FileInfo])}|%{$_.Name});};
$len=($first+$arr.length-1).toString().length;
Add-Type -TypeDefinition @'
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;
}
}
'@;
$list=[ExpDir]::Sort($arr);
for($i=0;$i -lt $list.length;$i++){
$newname=$first.toString()+' '+$list[$i];
if($addzero){$newname=$first.toString().PadLeft($len,'0')+' '+$list[$i];};
write-host ($list[$i]+' --> '+$newname);
$first++;
}
2020年03月01日 08点03分 3
1