Code References

Main class

class src.py_rename.RenameIt(dryrun, silent, full)

This is a generic Rename class with several methods for various types of renaming.

Constructor args:

Parameters:
  • dryrun (str, optional) – just a dry run, no actual renaming performed
  • silent (str, optional) – bare minimum will be printed
  • full (str, optional) – apply regex on full filenames only
bulk_rename(rename_func, *args)

Apply renaming function to multiple files

Parameters:
  • rename_func – specific renaming function to apply
  • args – args for the specific renaming function
Returns:

None

camel_case(filename)

Amend filename to camel case

Parameters:filename – str, filename
Returns:True
filename_pattern_rename(filename, pattern, replacement, match)

Rename or match regex pattern, do the rename and return True or False if matched

Parameters:
  • filename – str, filename
  • pattern – str, matching regex pattern
  • replacement – str, replacing regex pattern, can be None
  • match – match input based on re library
Returns:

True or False depending on if match or no match

lower_filename(filename)

Make filename all lowercase

Parameters:filename – str, filename
Returns:True
match_filename(filename, pattern, replacement, full)

Match filename function to generate matches

Parameters:
  • filename – str, filename
  • pattern – str, matching regex pattern
  • replacement – str, replacing regex pattern, can be None
  • full – boolean, apply matching pattern on full filename
Returns:

True or False based on filename pattern rename

postfix_filename(filename, postfix_str, include_ext=False)

Apply postfix to filename

Parameters:
  • filename – str, filename
  • postfix_str – str, postfix string to apply
  • include_ext – boolean, apply postfix to filename including file extension or not
Returns:

True

prefix_filename(filename, prefix_str)

Apply prefix to filename

Parameters:
  • filename – str, filename
  • prefix_str – str, prefix string to apply
Returns:

True

replace_space(filename, fill_char='_')

Replace spaces with a fill character

Parameters:
  • filename – str, filename
  • fill_char – str, char to replace spaces
Returns:

True

Argument parsing

src.main.parse_args(args)

Build argument parser function

Parameters:args – str, arguments to parser
Returns:parser args object

Main function

src.main.main()

Main function to read cli arguments and apply correct logic

Returns:None

Unit Tests

Unit tests for this library are using pytest.