Organizing folders

Automating folder organization means going through files with a script to sort, rename or archive them according to rules (extension, date, name). You use pathlib and shutil, doing a dry run first and avoiding overwriting existing files. A repeatable script replaces error-prone manual work.

Example

for f in Path('vrac').glob('*.pdf'):
    f.rename(Path('pdf') / f.name)

Related concepts

The whole glossary