Skip to content

From a target directory, rename all files, and in all sub directories, that satisfy rename rules.

Notifications You must be signed in to change notification settings

mwimpelberg28/file_renamer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 

Repository files navigation

File Renamer

This script inspects a target directory and will evaluate all files in the directory, and in all sub-directories, and rename any file whose name matches user-specified rename rules. Before running this script, you will need to specify the following values within 'file_renamer.py':

  1. target_path -- This is the root folder the script will inspect.

  2. replacements -- The keys of this dictionary will be substrings or regex patterns that you want to be replaced in an inspected file's name. The values of the dictionary will the values you want to replace the substring or regex pattern (key) with. For example, if you specify this:

    replacements = {
        "aloha": "hello"
    }
    

    ...then any inspected file containing the substring "aloha" in its name will have that sub- string replaced with "hello". If you have a file whose name is "aloha_world.txt" then the new file name would be "hello_world.txt".

  3. lowercase -- Default value is 'False'. If this is set to 'True', then an inspected file's new name will be forced to lowercase. Only files whose names would also cause them to be renamed by one of the 'replacements' rules will be affected.

  4. uppercase -- Same as above except as uppercase. If you set both 'lowercase' and 'uppercase' to 'True' it will throw a ValueError.

When the script is run you will be shown the total number of files and directories to be inspected, and asked to confirm the rename operation. If no files are found, the script will auto-abort. Hidden files and directores will not be inspected, nor will directory names be affected. Once a successful rename operation has been performed, a JSON log file will be created in the same directory that contains the script.

About

From a target directory, rename all files, and in all sub directories, that satisfy rename rules.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%