This is a python script that is designed to automate some file management tasks. It is designed to be run from the command line and supports various options to handle different scenarios.
This script is designed to work with Python 3. You must have Python 3 installed on your system in order to use this script.
To use this script, simply run it from the command line. Depending on the operating system you are using, you may need to modify the code to specify the path you want to work with.
The script supports several command line arguments that can be used to specify what action you want to perform.
Accepts a path-like string and prints out a dictionary of which the key is the matching word and the values is the list of matched files.
Accepts a path-like string (will be used for all as input for other argument).
Create folders in relation to the existing file extension in the path and moves the related files to the newly created folder. For example, example.mp4
will cause an mp4files
folder to be created.
Create a folder according to matching files and organize them (i.e the output from the -match/-m
).
Uses the create_ext_dir
function to make extension directories and uses the obr
function to arrange the files by name.
Empty the extension directories created and deletes them.
Used to delete a specific extension directory, e.g., mp4->mp4files
.
Used to create a specific extension directory, e.g., html->htmlfiles
.
Here are some examples of how you can use this script:
python file_manager.py -m "/path/to/files"
This command will match all files in the specified path that contain the word "word".
python file_manager.py -c -p "/path/to/files"
This command will create folders for each file extension in the specified path and move the related files into the newly created folder.
python file_manager.py -obr -p "/path/to/files"
This command will create a folder for each matching file and organize them accordingly.
python file_manager.py -obe -p "/path/to/files"
This command will create folders for each file extension in the specified path and move the related files into the newly created folder, then organize the files within each folder by name.
python file_manager.py -d -p "/path/to/files"
This command will empty the extension directories created and delete them.
python file_manager.py -de "mp4" -p "/path/to/files"
This command will delete the mp4files
directory in the specified path.
python file_manager.py -ce "html" -p "/path/to/files"
This command will create an htmlfiles
directory in the specified path.