Skip to content

A utility for spring cleaning a file directory by storing away its old subdirectories.

License

Notifications You must be signed in to change notification settings

jonboland/oldfolder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Old Folder

Black and white picture of stacks of old folders

Old Folder spring cleans a file directory by storing away subdirectories that haven't been modified for a given period.

Usage

Python 3.6+ must be preinstalled.

Old Folder can then be pip installed from PyPI and used via a command line interface:

F:\>oldfolder -h
usage: oldfolder [-h] [-t {modified,accessed,created}] path number storage

Move old subdirectories that contain files which haven't been modified for
a given period of time.
Moves can also be specified based on created or accessed time.

positional arguments:
 path                  Path of directory where subdirectories can be found.
 number                Number of years since files in subdirectories were
                       modified, accessed, or created.
 storage               Name of storage folder to place the old
                       subdirectories inside. The storage folder
                       location will be the specifed path.

optional arguments:
 -h, --help            show this help message and exit
 -t {modified,accessed,created}, --time_type {modified,accessed,created}
                       Time stat type to base the move on.

Or you can run it directly:

F:\>py oldfolder.py -h

Pass the path of the main directory, the length of time and the storage folder name to the program:

F:\>oldfolder "F:\main_directory" 1.5 "old_stuff"

Subdirectories that don't contain any files modified during the period will be listed for storage:

Based on the modified times of the files contained within them,
the subdirectories that will be moved to the old_stuff folder are:
         old_files_1
         old_files_2
Would you like to proceed?: Y/N

Before

F:\main_directory>tree /F
...
F:.
├───new_files_1
│   │   new_file.jpg
│   │
│   ├───second_level_folder_1
│   │       really_new_file.txt
│   │
│   └───second_level_folder_2
│           very_new_file.txt
│
├───new_files_2
│       fairly_new_file.txt
│
├───old_files_1
│   │   old_file.txt
│   │
│   └───second_level_folder_1
│       │   old_file_as_well.txt
│       │
│       └───third_level_folder
│               really_old_file.jpg
│
└───old_files_2
    │   another_old_file.txt
    │
    └───old_second_level_folder
            oldest_file.jpg
            old_file_2.txt

After

F:\main_directory>tree /F
...
F:.
 ├───new_files_1
 │   │   new_file.jpg
 │   │
 │   ├───second_level_folder_1
 │   │       really_new_file.txt
 │   │
 │   └───second_level_folder_2
 │           very_new_file.txt
 │
 ├───new_files_2
 │       fairly_new_file.txt
 │
 └───old_stuff
     ├───old_files_1
     │   │   old_file.txt
     │   │
     │   └───second_level_folder_1
     │       │   old_file_as_well.txt
     │       │
     │       └───third_level_folder
     │               really_old_file.jpg
     │
     └───old_files_2
         │   another_old_file.txt
         │
         └───old_second_level_folder
                 oldest_file.jpg
                 old_file_2.txt

You can read more about the program towards the end of this shutil article.

Importing

You can also use Old Folder's functions in your own projects:

import oldfolder


file_operations = oldfolder.prepare_move("F:\main_directory" 1.5 "old_stuff")

oldfolder.move_files(file_operations)

License

Old Folder is offered under the BSD 3 Clause license.

Protecting Your Data

As with other utilities that employ Python's shutil module to carry out high-level file operations, proceeding with caution and creating a backup of your data prior to use is strongly recommended.

Operating System

Old Folder is intended to be operating system independent, but has so far only been tested on Windows.

About

A utility for spring cleaning a file directory by storing away its old subdirectories.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages