返回列表 发帖

10元求助 文件移动的bat(已解决)

求2个批处理
1.
把相同前缀(点 下划线 数字)的相同英文的文件移动到,他相同名字的文件夹内

2.
把刚才移动好的文件夹内_0 到_6(最多到6),再移动到以为0-6为名字的文件夹内.

如果两个能合到一个也可!
支付方式 微信红包  
微信: wyl1212

本帖最后由 yhcfsr 于 2019-3-7 18:12 编辑
<# :
@echo off&cd/d "%~dp0"
more +8 "%~f0" >"%temp%\%~n0.ps1"
powershell -NoLogo -NoProfile -ExecutionPolicy bypass -File "%temp%\%~n0.ps1"
del /f /q "%temp%\%~n0.ps1"
pause
#>
$files = dir *.* -r -Exclude *.bat;
foreach($file in $files)
{
    $newpath = "$($file.Directory)\"+($file.BaseName -replace '_','\');
    if( !(Test-Path $newpath) ) {[void] (md $newpath);}
    Move-Item -Path $file -Destination $newpath
}COPY
QQ 33892006

TOP

@echo off
set "path=C:\Users\mac\Desktop\ceshi"
for /f "tokens=1,2,3* delims=_." %%a in ('dir "%path%" /b /a-d') do (
if not exist "%path%\%%a\%%b" mkdir "%path%\%%a\%%b"
move "%path%\%%a_%%b.%%c" "%path%\%%a\%%b\"
)
pauseCOPY
#&cls&@powershell "Invoke-Expression ([Io.File]::ReadAllText('%~0',[Text.Encoding]::UTF8))" &pause&exit

TOP

谢谢两位, 已解决! 非常感谢

TOP

返回列表