nameme

na·me·me | \na-me-me\
1. A simple utility to find the real filetype of a file based on its magic number and, optionally, rename it.

Usage

nameme is a CLI program that given a path prints the type of the contents the path based on the magic number of the content itself. For example, in a folder such as the following bash . ├── a ├── Cats │   ├── 1.jpg (* <- Actually a BMP image *) │   ├── 2.jpg │   ├── 3.jpg │   └── 4.jpg └─ Dogs    ├── 1.jpg    ├── 2.jpg    ├── 3.jpg (* <- Actually a GIF *)   └── 4.jpg invoking nameme . would print shell $ nameme . Format Results Erroneous BMP 1 1 GIF 1 1 JPG 7 0

To see which files are misnamed, you can use nameme --verbose: shell $ nameme --verbose . Format Results Erroneous BMP 1 1 ./Cats/1.jpg GIF 1 1 ./Dogs/3.jpg JPG 7 0 ./Cats/3.jpg ./Cats/5.jpg ./Cats/2.jpg ./Cats/4.jpg ./Dogs/1.jpg ./Dogs/2.jpg ./Dogs/4.jpg

The other use of nameme is that of automatically renaming files according to their magic number[^1]: shell $ tree . . ├── Cats │   ├── 1.jpg │   ├── 2.jpg │   ├── 3.jpg │   ├── 4.jpg │   └── 5.jpg └── Dogs ├── 1.jpg ├── 2.jpg ├── 3.jpg └── 4.jpg $ nameme --rename --auto . $ tree . . ├── Cats │   ├── 1.bmp │   ├── 2.jpg │   ├── 3.jpg │   ├── 4.jpg │   └── 5.jpg └── Dogs ├── 1.jpg ├── 2.jpg ├── 3.gif └── 4.jpg

If you prefer to be asked whether or not a certain file should be renamed, removing the --auto flag from the invocation in the previous example will make nameme ask you for each potential rename: shell $ nameme --rename . rename ./Cats/1.jpg -> ./Cats/1.bmp? [Y/n] y rename ./Dogs/3.jpg -> ./Dogs/3.gif? [Y/n] y

Todo

Items marked as complete in this list can still be improved.

Credits

This library and application are based on GCK's File Signatures Table, distributed under MIT license. Ideally, the user should be able to choose which of the available extension to choose, but this can get tedious really fast for large files.