Use Terminal to select multiple files by filetype and add extension

I need help using Terminal.


I have a Mac (OS Tiger!) where there are many files without extensions (unknown type) EVERY folder has a FINDER.DAT and a folder named RESOURCE.FRK

(I assume old Mac files, maybe OS 9, have been restored from PC formatted drive.)


It's easy to get rid of these files, but the extension-less files are still unknown types in the Finder.


I have learned that I find the filetype and encoding of a single file by typing this in Terminal:

file -I path/filename


But I would like to be able to select all extension-less files of one type (eg. jpg or Word) in one folder (and subfolders) and then add the correct extension to all of them.


Any ideas? :)


Cheers, Simon



MacBook

Posted on Apr 27, 2019 9:58 AM

Reply

Similar questions

7 replies

Apr 27, 2019 10:25 AM in response to Simon Beer1

Why not make use of one out of many file renaming utilities you will find either at the Mac Apple Store or MacUpdate? Much easier to use than the Terminal.


If you are trying to get these old files from OS 9 or earlier to work now that they have items stripped out, then you will get no success. Importing Mac files from an old PC as you have done will yield non-working files. This includes apps such as Word because it is not a single file but a package (bundle) of files made to work as an application package. Without all of its components it will simply not work on a Mac.

Apr 27, 2019 10:34 AM in response to Kappy

Hi Kappy. :)


I'm sure the originals were Mac files. Somehow they have gone to a PC drive and back again.


The files are mostly jpg or doc files. If i manually add the correct extension, they work fine!

Just to be clear, there are no applications.


These files don't have extensions, so Finder does not recognise them. Only Terminal can show the true format and filetype, so I assume only terminal can fix this… unless I do everything file by file! :D



Apr 27, 2019 11:37 AM in response to Simon Beer1

I do not know a Unix command for detecting filetypes. There is a Tcl command, fileutil, that can but to use it also requires installing Tcl, etc.


If you know the filetypes of multiple files, then you can move them into a separate folder. CD to the new folder and use "mv" to rename them all by adding the needed extension. That's what I have done.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Use Terminal to select multiple files by filetype and add extension

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.