unravel.utilities.rename module#
Use utils_rename
(name
) from UNRAVEL to recursively rename files and/or directories by replacing text in filenames.
Usage:#
utils_rename -o old_text -n new_text [-t files or dirs or both] [–recursive] [–dry_run] [-v]
- unravel.utilities.rename.rename_files(directory, old_text, new_text, recursive=False, rename_type='both', dry_run=False)[source]#
Renames files and/or directories in the specified directory, replacing old_text with new_text in the filenames. Can operate recursively and selectively based on type.
- Parameters:
directory (-) – the directory to search for files and/or directories
old_text (-) – the text to be replaced in the filenames
new_text (-) – the text to replace with in the filenames
recursive (-) – whether to perform the renaming recursively
rename_type (-) – what to rename: “files”, “dirs”, or “both” (default: both)
dry_run (-) – if true, print changes without making them