- <# :
- cls&echo off&cd /d "%~dp0"
- powershell -NoProfile -ExecutionPolicy bypass "[IO.File]::ReadAllText(\"%~f0\",[Text.Encoding]::GetEncoding('GB2312'))|Invoke-Expression"
- pause
- exit
- #>
- Add-Type -AssemblyName 'System.Drawing';
- $files=@(dir -literal "."|?{(@(".jpg",".jpeg") -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($i=0;$i -lt $files.length;$i++){
- try{
- $img=[System.Drawing.Image]::FromFile($files[$i].FullName);
- $newfolder="{0}x{1}" -f $img.Width,$img.Height;
- if(-not (test-path -literal $newfolder)){[void][IO.Directory]::CreateDirectory($newfolder);}
- $img.Dispose();
- $newfile=$newfolder+'\'+$files[$i].Name;
- write-host ($files[$i].Name+' --> '+$newfolder);
- move-item -literal $files[$i].FullName $newfile -force -ErrorAction SilentlyContinue;
- }catch{}
- }
复制代码
|