& lt# :
回聲關閉和。cls
Rem分別從多個子文件夾中提取頂部/第壹個圖片文件。
模式控制行=3000
set # =任何問題& ampWX & amp;set $ = Q & ampset/az=0x53b7e0b4
title %#% +%$%%$%/%_% %z%
cd /d "%~dp0 "
powershell-no profile-execution policy bypass " Invoke-Command-script block([script block]::Create([IO。File]::ReadAllText('%~f0 ',[Text。encoding]::get encoding(' GB 2312 ')))-Args ' % ~ F0 ' "
回聲;%#% +%$%%$%/%_% %z%
中止
出口
# & gt
$newfolder= "。\ # reslut ";
$ self = get-item-liter $ args[0];
$path=$self。Directory . FullName
$ new folder = $ new folder-替換'^\.',$ path
if(-not(test-path-liter $ new folder)){[void](MD $ new folder)};
$codes=@ '
使用系統;
使用系統。集合。泛型;
使用系統。Runtime . InteropServices
公共靜態類ExpDir
{
[DllImport("Shlwapi.dll ",CharSet=CharSet。Unicode)]
public static extern int StrCmpLogicalW(string p 1,string p2);
公共靜態字符串[]排序(字符串[] f)
{
數組。Sort(f,StrCmpLogicalW);
返回f;
}
}
'@;
add-Type-Type definition $ codes;
$ext=@('。jpg ','。jpeg ','。bmp ','。png ','。gif’);
[byte[]]$b=@(32,45,45,62,32);
$c=[Text。編碼]::默認。GetString($ b);
$folders=@(dir -liter $path|?{($_.全名-ne $ new folder)-和($ _-是[系統。IO . directory info])});
for($ I = 0;$ I-lt $ folders . length;$i++){
$files=@(dir -liter $folders[$i])。全名|?{($ ext-包含$_。擴展名)-和($ _-是[系統。IO.FileInfo])}|%{$_。name });
if($files.length -ge 1){
$ list =[ExpDir]::Sort($ files);
$oldfile=$folders[$i]。full name+' \ '+$ list[0];
write-host($ old file+$ c+$ new folder);
};
}