This script is designed to recover the file name extension from a given path and rename the files accordingly. It is particularly useful for files that are photos or videos without any extension.
-
Clone the Repository: Clone this repository to your local machine.
-
Install Requirements: Make sure you have Python installed on your machine. Additionally, install the required packages by running:
pip install tqdm
-
Run the Script: Navigate to the directory where the script is located and run it by executing the following command:
python file_extension_recovery.py
-
Input Path: Provide the path to the directory containing the files you want to recover extensions for. Modify the
path
variable in the script accordingly. -
Review Output: Once the script is executed, it will recover extensions for files without extensions and rename them accordingly.
Suppose you have a directory containing files named MGYM6489
, IMG001
, VIDEO123
, etc. After running the script, these files will be renamed to MGYM6489.heic
, IMG001.jpg
, VIDEO123.mp4
, etc., based on their detected extensions.
- This script relies on file signatures (magic numbers) to identify the file type and recover the extension. Therefore, it may not work correctly for all file types.
- Make sure to provide the correct path to the directory containing the files you want to process.
- Use caution when running the script, as it will rename files in the specified directory.