A
A
Andrey Larin2018-10-19 21:42:32
linux
Andrey Larin, 2018-10-19 21:42:32

How to automatically fix file extensions based on their content?

Hello, I have a set of files (videos, pictures, etc.) some of which have incorrect extensions, such as *.png for JPEG files, etc.
I myself came up with a not very convenient "crutch" in the form of selecting all files and mass renaming in "double commander":
5bca24390b917253978263.pngDisadvantages:
➖ All files are renamed, even with correct names.
➖ Files like *.ion are renamed
➖ No log
➖ Then you have to rename again, cutting out part of the extension
I would like to:
Have some kind of console utility that scans a directory when it starts, then displays a list of files without an extension or with an incorrect extension. Then displays the dialog "rename? n / n" and would change the names of the files.
Perhaps such software already exists, perhaps it’s easy to write it yourself (which I don’t know how to do, but I think I can do it). I will be glad for any hint.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AVKor, 2018-10-19
@AVKor

man fileand write your own shell script.

N
Nikita Vorobyov, 2018-10-20
@Homa200

there is a man file. And you can do everything by hand.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question