Page 1 of 1

getting camera info from bath file?

Posted: 19 May 2015 12:49
by tcpman
as many of you guys know when we take a picture with our camera and then send it to our computer if we open the propertes
we can see the model and the company name of the camera!
now i want to save this model and company name into a text file
but i just dont know how!
i though it will be possible using wmic to get the info i need but i did not see anything in wmic helps that can do this job
so i want to ask is this possible to do?
its okey if i can use poweshell or vbs just want to do it using a script

Re: getting camera info from bath file?

Posted: 19 May 2015 13:52
by penpen
The ExifTool may help you:
http://www.sno.phy.queensu.ca/~phil/exiftool/.


penpen

Re: getting camera info from bath file?

Posted: 21 May 2015 09:44
by tcpman
well i am still looking for a way using vbs,cmd,powershell
but if no luck then i will use this
tnx my friend.

Re: getting camera info from bath file?

Posted: 21 May 2015 16:25
by Compo
tcpman wrote:well i am still looking for a way using vbs,cmd,powershell

Here's all I'm willing to provide: (this isn't a powershell group)

Get-ImgCamNfo.ps1

Code: Select all

param([string]$path = (get-location), 
    [string]$fileType = ".jpg")
clear
Add-Type -AssemblyName System.Drawing
$filter = "*" + $fileType
$Encode = new-object System.Text.ASCIIEncoding
$files = get-childitem -recurse $path -filter $filter
$image = $null
$filesource = $null
if ($files -ne $null)
{
    foreach ($file in $files)
    {
        $image = [System.Drawing.Imaging.Metafile]::FromFile($file.FullName)
        try
        {
            $filesource = $image.GetPropertyItem(41728).Value[0]
            $makerByte = $image.GetPropertyItem(271)
            $imageMaker = $Encode.GetString($makerByte.Value)
            $modelByte = $image.GetPropertyItem(272)
            $imageModel = $Encode.GetString($modelByte.Value)
            $image.Dispose()   
        }
        catch
        {
        }
        if(($filesource -eq 3) -and ($imageMaker -ne $null) -and ($imageModel -ne $null))
        {
            write $file.fullname $imageMaker $imageModel `r`n
        }
    }
}
else
{
    Write-Host "No files found"
}
You should run it in the ISE with a command such as:

Code: Select all

.\Get-ImgCamNfo.ps1 -path F:\Data\MyPics -fileType .jpg
...obviously change the top level directory and file extension to suit your specific task.

Re: getting camera info from bath file?

Posted: 22 May 2015 09:15
by tcpman
thank you !
you saved my day!

Re: getting camera info from bath file?

Posted: 24 May 2015 20:03
by Endoro
Compo wrote:Here's all I'm willing to provide: (this isn't a powershell group)

So please do not provide Powershell code here, except in hybrid cmd shell command files.
Thank you

Re: getting camera info from bath file?

Posted: 25 May 2015 03:06
by Compo
Endoro wrote:
Compo wrote:Here's all I'm willing to provide: (this isn't a powershell group)

So please do not provide Powershell code here, except in hybrid cmd shell command files.
Thank you

How ironic that three days after my solution and its subsequent acknowledgement that you should highlight the pointlessness of my content!