One thing really silly is the way digital cameras name their files : dsc00001.jpg or something similar, which is quite annoying when you try to sort old pictures. So I made a small bash script that renames every picture with a more useful filename : 041131-001.jpg for example. To do so, I'm using a Perl script I've made, datemodif, which outputs a modification date in various formats, but I wanted to do a more portable script, using only Bash and default GNU utils, but not Perl.
After some testing, here is the function I've added to my .bash_profile :
- function getmodif {
- stat -c "%y" $1 | cut -d" " -f1 | sed -e 's/..//' -e 's/-//g'
- }
Sample output :
- [ozh@SARL ~/htdocs/ozh]$ ls -l index.php
- -rw-r--r-- 1 sarl 515 20728 nov 30 23:13 index.php
- [sarl@SARL ~/htdocs/ozh]$ getmodif index.php
- 041130
Shorter URL
Want to share or tweet this post? Please use this short URL: http://ozh.in/3m
Silly but very useful. Thanks a lot.