Skip to content

The sort Command

Sam Matzko edited this page Dec 11, 2021 · 3 revisions

The sort command provides the basis for all Sortery's advanced sorting. It takes up to three arguments: the date-format option, the date-type option, and the preserve-name flag, none of which are required.

The Date Format Option (--date-format)

This flag takes a string argument representing the template date format for renaming the files. The default is %Y-%m-%d %Hh%Mm%Ss; for example, 2021-12-25 15h05m58s. See the chrono docs for details on specific formatting options. Be sure to put quotes around the template format: --date-format="%Y-%m-%d %Hh%Mm%Ss".

The Date Type Option (--date-type)

This flag takes an argument, which must be one of c, m, or a, that specifies the specific date to sort the files by. The table below shows each option and how it sorts the files:

Option How it sorts
a Sort all the files by access time: the last time each file was accessed.
c Sort all the files by creation time: the time each file was created.
m Sort all the files by modification time: the time each file was last modified.

The Preserve Name Flag (-p, --preserve-name)

This flag takes no arguments. When passed, it tells Sortery to preserve the original name of each file when sorting, by putting the original name after the date, separated by a space. So if we have a file1.txt, and the preserve-name flag is passed, instead of renaming file1.txt to 2021-12-25 15h05m58s.txt, Sortery will rename it to 2021-12-25 15h05m58s file1.txt.

Clone this wiki locally