
[已解決]批處理怎樣批量提取圖片屬性最后由 guliduo 于 -11-11 23:03請問大家怎么添加命令實現(xiàn)將當前文件夾和子文件夾下的圖片屬性也一起提取出來?然后把提取文件名改為提取圖片路徑,并輸出時在第一行添加上標題原代碼如下:
nclick="copycode($('code0'));">復制代碼
- <# :
- cls
- @echo off
- rem 提取圖片的文件大小、寬高尺寸和分辨率
- set #=Any question&set @=WX&set $=Q&set/az=0x53b7e0b4
- title %#% +%$%%$%/%@% %z%
- cd /d %~dp0
- powershell -NoProfile -ExecutionPolicy bypass Invoke-Command -scriptBlock ([scriptBlock]::Create([IO.File]::ReadAllText('%~f0',[Text.Encoding]::Default))) -Args '%~dp0'
- echo;%#% +%$%%$%/%@% %z%
- pause
- exit
- #>
- $path=$args[0];
- $outfile='.info.csv';
- $ext=@('.jpg', '.jpeg', '.bmp', '.png', '.gif', '.TIF');
- function formatsize($n){
- $m='';
- if($n -ge 1073741824){
- $m=($n/1073741824).toString('0.00')+' GB';
- }else{
- if($n -ge 1048576){
- $m=($n/1048576).toString('0.00')+' MB';
- }else{
- if($n -ge 1024){
- $m=($n/1024).toString('0.00')+' KB';
- }else{
- $m=$n.toString()+' B';
- };
- };
- };
- return $m;
- };
- $outfile=$outfile -replace '^.',$path.trimend('');
- [System.Collections.ArrayList]$s=@();
- Add-Type -AssemblyName 'System.Drawing';
- $files=@(dir -liter $path|?{($ext -contains $_.Extension) -and ($_ -is [System.IO.FileInfo])});
- for($i=0;$i -lt $files.length;$i++){
- $img=[System.Drawing.Image]::FromFile($files[$i].FullName);
- $line=''+$files[$i].Name+','+(formatsize $files[$i].length)+',';
- $line+=$img.Width.toString()+'x'+$img.Height.toString()+','+$img.HorizontalResolution.toString();
- [void]$s.add($line);
- write-host $line;
- $img.Dispose();
- };
- [IO.File]::WriteAllLines($outfile, $s, [Text.Encoding]::Default);

