Windows 7 탐색기 검색을 사용하여 종횡비로 비디오 / 이미지를 검색하는 방법 (사진, 비디오) 을 검색 할

를 사용하여 특정 크기의 파일 (사진, 비디오) 검색 할 수 있다는 것을 알고 있습니다 width:1920, height:1080.

그러나 Windows 7에서 16 : 9 종횡비를 가진 파일을 어떻게 검색합니까?



답변

Windows 7 탐색기 검색에서는 불가능합니다


그러나 여기에 필수 Windows 부품에 의존하는 대안이 있습니다.

이미지 (PowerShell 2.0)

주어진 루트 폴더에서 모든 이미지를 읽고 너비를 기준으로 이미지를 나누고 결과를 예 16/10와 비교 하고 비율이 일치하면 전체 경로를 출력합니다

Get-Childitem "D:\MyPictures" -include @("*.jpg","*.png") -recurse | Where {
    $img = New-Object System.Drawing.Bitmap $_.FullName

    if ($img.Width / $img.Height -eq 16/10 -or
        $img.Height / $img.Width -eq 16/10) {
        Write-Host $_.FullName
        }
  }

이미지 (PowerShell 2.0) -자르기 / 비표준 종횡비에 대한 개선 된 버전

$folder      = "C:\Users\Public\Pictures\Sample Pictures"
$searchRatio = 4/3
$AllRatios   = (16/10),(16/9),(4/3),(5/4),(21/10),(21/9)
$filetypes   =  @("*.jpg","*.png","*.bmp")

Clear-Host
Get-Childitem $folder -include $filetypes -recurse | foreach {
    $img = New-Object System.Drawing.Bitmap $_.FullName
    if ($img.Width -gt $img.Height){ $fileRatio = $img.Width / $img.Height }
    else {$fileRatio = $img.Height / $img.Width}

    $differences = $AllRatios | %{  [math]::abs($_ - $fileRatio) }
    $bestmatch = $differences | measure -Minimum
    $index = [array]::IndexOf($differences, $bestmatch.minimum)
    $closestRatio = $($AllRatios[$index])

    if ($closestRatio -eq $searchRatio) {
        Write-Host $fileRatio `t`t $_.FullName
        }
  }

설명

  1. 대부분의 사진이 잘린 사진이있는 폴더가 있다고 가정합니다. 따라서 16 : 9와 같은 표준 종횡비가 없습니다. 이들을 위해이 스크립트는 항상 표준 종횡비와 가장 가까운 것을 검색합니다. 당신은 그들을 확장 할 수 있습니다 $AllRatios = (16/10),(16/9),(4/3),(5/4),(21/10),(21/9)당신이 원하는 경우

  2. 다른 3 개의 변수는 스스로 설명해야합니다. $folder검색하려는 폴더입니다. 찾고자 $searchRatio하는 종횡비 $fileTypes이며 관심있는 사진 유형을 정의합니다.


비디오 용 (PowerShell 2.0 + ffprobe )

$folder      = "D:\My Videos\*"
$ffprobe     = "D:\ffmpeg\ffprobe.exe"
$searchRatio = "13:7"
$filetypes   = @{"*.avi","*.mp4"}

Clear-Host
Get-ChildItem $folder -include $filetypes -recurse | foreach {
    $details = & $ffprobe -loglevel quiet -show_streams -print_format flat=h=0 $_.Fullname
    $fileratio = $details | Select-String '(?<=stream.0.display_aspect_ratio=")\d+:\d+' |
       Foreach {$_.Matches} | ForEach-Object {$_.Value}

    if ($fileratio -eq $searchRatio ) {
        Write-Host $fileratio `t`t $_.FullName
    }
}

설명

  1. ffmpeg의 ffprobe를 사용 하여 비디오에서 모든 정보를 검색 할 수 있습니다

    명령

    ffprobe -loglevel quiet -show_streams -print_format flat=h=0 input.mp4
    

    출력 예

    stream.0.index=0
    stream.0.codec_name="mpeg4"
    stream.0.codec_long_name="MPEG-4 part 2"
    stream.0.profile="Advanced Simple Profile"
    stream.0.codec_type="video"
    stream.0.codec_time_base="911/21845"
    stream.0.codec_tag_string="XVID"
    stream.0.codec_tag="0x44495658"
    stream.0.width=624
    stream.0.height=336
    stream.0.has_b_frames=1
    stream.0.sample_aspect_ratio="1:1"
    stream.0.display_aspect_ratio="13:7"
    stream.0.pix_fmt="yuv420p"
    stream.0.level=5
    
  2. 다음으로 Regex를 사용하여 종횡비를 필터링합니다 ( 13:7이 예에서는).

  3. 마지막으로 비디오 비율을 검색 비율과 비교하고 일치하는 경우 파일 경로를 출력합니다

답변