for file in *.pdf; do
if [[ $(file “$file”) == *”JPEG image data”* ]]; then
echo “$file is actually a JPEG image”
fi
done

Get-ChildItem -Filter “*.txt” | ForEach-Object {
$file = Get-Item $_.FullName
$stream = [System.IO.FIle]::OpenRead($file.FullName)
$bytes = New-Object byte[] 2
$stream.Read($bytes, 0, 2) | Out-Null
$stream.Close()

# JPEG files typically start with the byte sequence 0xFF , 0xD8
if ($bytes[0] -eq 0xFF -and $bytes[1] -eq 0xD8) {
Write-Output “$($_.FullName) is likely a JPEG image.”
} else {
Write-Output “$($_.FullName) is not a JPEG image.”
}
}

Leave a Reply