@echo off
rem 根据从文件名中指定字符串/关键词开始截取指定位数的字符来移动文件到对应文件夹
set #=q&set/azx=0x53b7e0b4
title Any question +%#%%#% %zx%
cd /d "%~dp0"
set "keyword=20191231"
set "n=15"
powershell -NoProfile -ExecutionPolicy bypass ^
$files=@(dir^|?{($_ -is [System.IO.FileInfo]) -and ($_.Name -ne '%~nx0')});^
for($i=0;$i -lt $files.length;$i++){^
$n=$files[$i].BaseName.IndexOf('%keyword%');^
if($n -ge 0){^
$s=$files[$i].BaseName.Substring($n);^
if($s.length -ge %n%){^
$kw=$s.Substring(0,%n%);^
[void](md $kw -force);^
$txt=$files[$i].Directory.FullName+'\'+$kw+'\%n%.txt';^
out-file -file $txt -input $kw -enc Default;^
write-host ($files[$i].Name+' --^> '+$kw);^
mv -liter $files[$i].FullName ($files[$i].Directory.FullName+'\'+$kw);^
};^
};^
}
echo;Any question +%#%%#% %zx%
pause