HI, I use EXIFTOOL to extract the information from the image
When I extracted the information from a certain image it retrieved this data:
Exiftool.exe .\1.jpg
ExifTool Version Number: 12.55
File Name: 1.jpg
Directory:
File Size: 2.0 MB
File Modification Date/Time : 2022:12:19 04:06:54+02:00
File Access Date/Time : 2023:01:27 14:58:43+02:00
File Creation Date/Time : 2023:01:27 14:58:36+02:00
File Permissions: -rw-rw-rw-
File Type: JPEG
File Type Extension: jpg
MIME Type: image/jpeg
Exif Byte Order : Little-endian (Intel, II)
Make: Canon
Camera Model Name: Canon EOS R6
X Resolution: 240
Y Resolution: 240
Resolution Unit: inches
Software: Adobe Photoshop Lightroom Classic 11.1 (Windows)
Modify Date : 2022:12:17 13:04:09
Exposure time: 1/160
F Number: 4.0
Exposure Program: Manual
ISO: 3200
Sensitivity Type: Recommended Exposure Index
Now I ran this commands:
exiftool -FileSize -if "$FileSize eq '2.0'" .
AND
exiftool -FileSize -if "$FileSize eq 2.0" .
But it returns this value
1 files failed condition
On the image from which I extracted the EXIF data
what could be the problem?
Thanks!
The value of FileSize is "2.0 MB", not "2.0"
Example:
C:\>exiftool -G1 -a -s -filesize y:\!temp\Test4.jpg
[System] FileSize : 446 kB
C:\>exiftool -G1 -a -s -if "$FileSize eq '446'" -FileSize y:\!temp\Test4.jpg
1 files failed condition
C:\>exiftool -G1 -a -s -if "$FileSize eq '446 kB'" -FileSize y:\!temp\Test4.jpg
[System] FileSize : 446 kB
Quote from: StarGeek on January 27, 2023, 12:02:35 PMThe value of FileSize is "2.0 MB", not "2.0"
Example:
C:\>exiftool -G1 -a -s -filesize y:\!temp\Test4.jpg
[System] FileSize : 446 kB
C:\>exiftool -G1 -a -s -if "$FileSize eq '446'" -FileSize y:\!temp\Test4.jpg
1 files failed condition
C:\>exiftool -G1 -a -s -if "$FileSize eq '446 kB'" -FileSize y:\!temp\Test4.jpg
[System] FileSize : 446 kB
I tried to do as you wrote, but it doesn't work for me
I have the newest version of Exiftool
(https://i.imgur.com/sV44f5G.png)
You're using PowerShell. Notice how $Filesize is highlighted differently. That indicates PS is treating it as a PowerShell variable and passes an empty value to exiftool. You have to pay attention to the highlighting if you use PS.
Doing some testing just deepens my dislike of PS. I thought you could just swap the quotes with PowerShell the way that Mac and Linux does, but I'm now discovering that doesn't work. I can't figure out a way in which swapping the quotes works. So it looks like the only solution is to use double quotes and escape the dollar sign with a backtick
PS C:\> exiftool -G1 -a -s -filesize y:\!temp\Test4.jpg
[System] FileSize : 449 kB
PS C:\> exiftool -G1 -a -s -if "$FileSize eq '449 kB'" -FileSize y:\!temp\Test4.jpg
1 files failed condition
PS C:\> exiftool -G1 -a -s -if "`$FileSize eq '449 kB'" -FileSize y:\!temp\Test4.jpg
[System] FileSize : 449 kB
Or just use CMD, as there are a bunch of other problems when using PS with exiftool.
Quote from: StarGeek on January 28, 2023, 09:24:58 PMYou're using PowerShell. Notice how $Filesize is highlighted differently. That indicates PS is treating it as a PowerShell variable and passes an empty value to exiftool. You have to pay attention to the highlighting if you use PS.
Doing some testing just deepens my dislike of PS. I thought you could just swap the quotes with PowerShell the way that Mac and Linux does, but I'm now discovering that doesn't work. I can't figure out a way in which swapping the quotes works. So it looks like the only solution is to use double quotes and escape the dollar sign with a backtick
PS C:\> exiftool -G1 -a -s -filesize y:\!temp\Test4.jpg
[System] FileSize : 449 kB
PS C:\> exiftool -G1 -a -s -if "$FileSize eq '449 kB'" -FileSize y:\!temp\Test4.jpg
1 files failed condition
PS C:\> exiftool -G1 -a -s -if "`$FileSize eq '449 kB'" -FileSize y:\!temp\Test4.jpg
[System] FileSize : 449 kB
Or just use CMD, as there are a bunch of other problems when using PS with exiftool.
you're the best!
You helped me a lot and now it works like a charm in CMD shell
Thank you very much for solving the problem ;D