Page 1 of 1

how to rename unknown file type

PostPosted: Tue Nov 14, 2017 6:04 pm
by WMC111
Hi, I'm new here. Does this utility have the ability to determine file type and give it the appropriate extension in the name? For example I have a folder with lots of image files but some are jpg some are tiff but none of them have an extension. Can this BRU look at each file, determine whether it is a jpg or tiff and rename it with the jpg or tiff extension?

Re: how to rename unknown file type

PostPosted: Tue Nov 14, 2017 8:22 pm
by therube
AFAIK, no it does not do that.
It appears to accept the file extension (or not), as it is.


Does the extension need to be accurate?
Do you necessarily need to differentiate between jpg & tiff?
And if not, simply rename all the files as jpg.
(You would think any "image" program would correctly open a file, assuming it can, regardless of its extension.)
[That will not always be the case, though. Seem to recall, some audio program that took it for granted that the file extension was accurate for the file it was given - rather then actually checking.]


You can open a file with no (or wrong) extension in IrfanView & assuming it can figure out what type of file it is, it will offer to rename it. (Though that may only be on a 1 by 1 basis.)

Actually, if you do something like rename all the files as jpg, then open "the first" in IrfanView, then [space-bar] to subsequent images, as it comes to a file with a wrong extension (i.e., tiff), it will offer to rename it for you. Still not "automated", but depending on the number of files, might not be to bad a way to go about it.

(Don't know if IrfanView has an automated way to do that?)


----


If you need bulk... there is "magic".

Magic will give you something like:

Code: Select all
Residential Property Registration 2017;                    PNG image, 1298 x 9381, 8-bit colormap, non-interlaced
BRU mushy fruit cat-1;                                     PNG image, 1418 x 614, 8-bit colormap, non-interlaced
BRU mushy fruit cat-2;                                     PNG image, 1450 x 615, 8-bit colormap, non-interlaced
Clear Firefox Profile data(size) 21-Aug;                   JPEG image data, JFIF standard 1.01
Everything - Crystal Floyd limiting search;                PNG image, 680 x 1311, 8-bit colormap, non-interlaced
Everything File Menu Shortcut Keys;                        PNG image, 1165 x 533, 8-bit colormap, non-interlaced
Bytecc Micro USB Male to USB Female OTG Adapter;           PNG image, 1039 x 1007, 8-bit colormap, non-interlaced

First column is the file name (as named, no extension in this case).
Second column is what it "determines" the file type to be.

With that... you could massage the data... you'd have to work at it...

So... {pseudo-code}

everything up to ; == filename
; & following spaces is removed
next "word" is the extension
everything after extension is removed

so now you have filename & extension
& just combine them, filename.extension

With that, finagled, you could use BRU's Import-Pairs feature.
Or just do everything a DOS FOR loop.

---
https://sourceforge.net/projects/gnuwin32/files/file/5.03/file-5.03-bin.zip/download

From within there, you'll need:

file.exe (I renamed file.exe to file_gnuwin32.exe)
magic
magic.mgc
magic1.dll


Then use a command-line (or put it in a batch file) like:

file_gnuwin32.exe -m magic %1 %2 %3

Re: how to rename unknown file type

PostPosted: Wed Nov 15, 2017 12:14 pm
by Admin
If you can put the old name and new name with correct extension in a text file using other software, then you can use the bulk rename pairs functionality to rename the files with correct extension.

Re: how to rename unknown file type

PostPosted: Wed Nov 15, 2017 2:17 pm
by WMC111
Thank you all for the information! It didn't occur to me that windows picture view would open the file even if it has the wrong extension so I think giving all my files a jpg extension will work. I have several hundred image files and will be using an Access database application to open them as a thumbnail then double click that to open with windows image viewer. I think this will work but if it doesn't then you've given me some good directions to go in. Thanks !