kapott icon

datetag.sh

kapott | PRO | 01/04/19 02:16:06 PM UTC | 0 ⭐ | 305 👁️ | Never ⏰ | []
Bash |

340 B

|

None

|

0 👍

/

0 👎

#!/bin/bash
#
# datetag.sh
# Usage: datetag.sh <filename>
#
# Will rename a file, and prepend ISODate of the last modified stamp
# in front of the filename; 
# eg testfile.txt with a last modified timestamp of september 1st, 2018
# will become 20180901_testfile.txt
 
mod_date="$(stat -c %y ${1} | awk '{print $1}')"
mv ${1} ${mod_date}_${1}

Comments