-
Notifications
You must be signed in to change notification settings - Fork 0
Command line Options
This page contains in-depth explanations of how the command-line arguments work, how to use them, and in some cases the source code relating to the argument.
The SOURCE and TARGET arguments make up the base of all Sortery functionality, and are thus required. They are the two directories used in sorting. It depends on the arguments/flags you use, but generally, SOURCE is where the files-to-be-sorted are contained, and TARGET is the directory into which files are sorted. If either of SOURCE or TARGET is a path that doesn't exist, Sortery will print an error message for each path and exit without executing the sort.
The extract flag tells Sortery to move everything from SOURCE into TARGET, while maintaining subdirectory structure. For example: we have a directory with a structure that looks like this:
source/
source/
- target/
- - file4
- file1
- file2
- file3
If we want to move everything from source/ to target/, we would use the extract flag:
sortery -e source/ target/
Sortery automatically detects if TARGET is inside SOURCE, and if it is, does not sort it. Now, source/ should look like this:
source/
source/
- target/
- - file4
- - file1
- - file2
- - file3
The --by-date flag sorts all files in SOURCE by date into TARGET, renaming the files according to their creation date and time and creating the necessary directories along the way. SOURCE and TARGET cannot be inside each other, although I may change that later on. Here is how you would use it:
sortery --by-date source/ target/
Assuming we have this directory structure:
show
source/
- file1
- file2
- file3
target/
Where file1 was created on Jun 1, 2021 at 3:05 PM, file2 was created on August 17, 2017 at 8:57 AM, and file3 was created on January 8, 2021 at 12:16 PM. Running the above command sorts file1 and file2 into year and month directories; the year directories named in yyyy format and the month directories in mm format. If any year or month directory already exists, the files are just moved inside it.
Here is the resulting directory:
show
source/
target/
- 2017/
- - 2017-08-17 8h57m0s. <-- this used to be file2
- 2021/
- - 2021-01-08 12h16m0s. <-- this used to be file3
- - 2021-06-01 15h05m0s. <-- this used to be file1
More specific and customizable date sorting and naming will be coming soon.