tglob - chronological globbing for a linux shell
tglob is a python script that acts like an asterisk in a linux shell, except it sorts the files chronologically.
For example, the command
mplayer *plays all the files in the current directory to mplayer in alphabetical order, but, assuming tglob is in your path, the command
tglob mplayerplays all the files in the current directory in chronological order, and
tglob -d ~/Music -n 10 -r mplayerplays the 10 oldest files in the directory ~/Music.
Features
- Limit number of files (-n N): Limit to a maximum number of files, instead of listing all the files in the directory. Useful if you only want to see the latest or the oldest few files.
- Shuffle slightly (-s N): Return the list of files in almost chronological order. The first file will be one of the most recent N files but not necessarily the most recent. Useful, for example, if you like listening to more recently downloaded songs but don't want the exact same order every time.
- Reverse order (-r): Return the files oldest first instead of newest first.
Installing
Just download tglob.py and put it in your path.
I like renaming it to just "tglob" (without the .py) but that's just my preference.
Make sure it is executable, or else you will have to call it with python, e.g. "python /path/to/tglob.py mplayer" or something like that.
Download
The source file is here: tglob.py
Changes
- 2012-01-20: Fixed an out-of-range bug when using -s option