Wrong FileTypeExtension

Started by UKenGB, January 01, 2020, 11:56:10 AM

Previous topic - Next topic

UKenGB

Audiobook files with the .m4b extension are being reported as FileType M4A which is correct, but FileTypeExtension is also m4a which is clearly wrong.

Would I not be correct in thinking that FileTypeExtension should actually be set from the file name?

Phil Harvey

FileTypeExtension is the extension derived from the FileType.  The idea is that this could be used to rename the file to add an extension if it didn't have one.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Is there actually a way to tell the difference?  From what I can tell online, there isn't any difference between m4a and m4b.  The m4b extension only exists to let iTunes know that it needs to keep track of what you've listened to (bookmarks).
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

UKenGB

Quote from: StarGeek on January 01, 2020, 01:09:53 PM
Is there actually a way to tell the difference?  From what I can tell online, there isn't any difference between m4a and m4b.  The m4b extension only exists to let iTunes know that it needs to keep track of what you've listened to (bookmarks).

Yes, I believe they are the same format and iTunes just uses the extension as an indicator that it's a book.

UKenGB

Quote from: Phil Harvey on January 01, 2020, 01:06:04 PM
FileTypeExtension is the extension derived from the FileType.  The idea is that this could be used to rename the file to add an extension if it didn't have one.

- Phil

That doesn't make any sense to me as that makes it redundant since on all files I looked at, both tags are the same (except for case). Seems to me that FileTypeExtension ought to be the extension taken from the file, or is there another tag for that?

In the end I extracted it myself from the filename, but if it already existed as a tag it would save an extra step - and failed script until I discovered the discrepancy and inserted my own fix.

Phil Harvey

The FileType tag isn't the same as the extension for some files.  For example:

% exiftool t/images/ -filetypeextension -filetype -T | sort | uniq
a Mach-O static library
aa AA
aae AAE
afm AFM
aiff AIFF
ape APE
avi AVI
bmp BMP
bpg BPG
btf BTF
cr2 CR2
cr3 CR3
crw CRW
dcm DICOM
dfont DFONT
djvu DJVU (multi-page)
dng DNG
docx DOCX
dpx DPX
dr4 DR4
dss DSS
dv DV
dylib Mach-O dynamic link library
eip EIP
eps EPS
exe Win32 EXE
exr EXR
fits FITS
flac FLAC
flif FLIF
flv FLV
fpf FPF
gif GIF
gz GZIP
hdr HDR
heif HEIF
html HTML
icc ICC
ics ICS
iiq IIQ
indd INDD
inx INX
iso ISO
itc ITC
j2c J2C
jp2 JP2
jpg JPEG
json JSON
lfp LFP
lnk LNK
m4a M4A
mie MIE
miff MIFF
mkv MKV
mobi MOBI
moi MOI
mov MOV
mp3 MP3
mpc MPC
mrw MRW
mts M2TS
mxf MXF
nef NEF
numbers NUMBERS
ods ODS
ogg OGG
opus OPUS
pcd PCD
pcx PCX
pdf PDF
pfa PFA
pfb PFB
pfm PFM
pgf PGF
pict PICT
plist PLIST
pmp PMP
png PNG
ppm PPM
ppt PPT
psd PSD
psp PSP
r3d R3D
ra RA
raf RAF
ram RAM
raw RAW
rm RM
rtf RTF
rw2 RW2
so ELF shared library
svg SVG
swf SWF
tif TIFF
torrent Torrent
ttf TTF
txt TXT
vcf VCard
vrd VRD
wav WAV
webp WEBP
wmv WMV
wtv WTV
x3f X3F
xcf XCF
xmp XMP
zip ZIP


This may make more sense if you realize that some different file types have the same extension.  So if you want a unique FileType, it can't be the same as the extension for these files.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

StarGeek

Quote from: UKenGB on January 02, 2020, 12:43:56 PMYes, I believe they are the same format and iTunes just uses the extension as an indicator that it's a book.

One of the main uses of the FileTypeExtension is to add/correct filenames that are either missing an extension, such as might be the result of a recovery program, or have an incorrect extension.  If there's nothing about the file structure to differentiate between two similar file types, then exiftool can't tell if it's one file type or the other.  You would have similar problems with programs like file or websites where you upload a file to determine the file type such as CheckFileType.com

Quote from: UKenGB on January 02, 2020, 12:49:13 PM
That doesn't make any sense to me as that makes it redundant since on all files I looked at, both tags are the same (except for case).
See above.

Quoteis there another tag for that?
No specific tag, but in some cases, such as renaming or using the -o, -w, or -TagsFromFile options, you can use the %e variable (see the -w (textout) option for details).  For other operations you can use ${FileName;s/.*\.([^.]*)/$1/} to just use the extension.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Alan Clifford

http://f16.eu/bits/wink200.jpg

@StarGeek commented whilst I was trying to find the "jpg" in the link. 

I see that Firefox does identify the file as a gif but still plays it.

Filename extentions are quite dangerous.  I pursuaded (just to see if I could) the person compiling the online telephone directory at work that the photo they had of me wasn't very nice and could they use this one.  (It was a slightly different version as I didn't want to give the game away by it winking after only 2 seconds)

StarGeek



Use [img]http://f16.eu/bits/wink200.jpg[/img] or click the button above the text box.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Alan Clifford

Quote from: StarGeek on January 02, 2020, 06:56:50 PM

Use [img]http://f16.eu/bits/wink200.jpg[/img] or click the button above the text box.

That shows the picture.  But it doesn't show that the file extention is .jpg which is what I wanted to show.

StarGeek

Ah, yes of course.  Another of my Homer moments.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype