diff options
author | Stijn Buys <ingar@telenet.be> | 2022-08-28 11:44:07 +0200 |
---|---|---|
committer | Stijn Buys <ingar@telenet.be> | 2022-08-28 11:44:07 +0200 |
commit | 7329ffa21452841d5c5ef56d4f9ba150417f6f50 (patch) | |
tree | 955b7c246039e7a019a3c338ed4e332ad3e86e9a /dcimdirsort |
Initial commit.
Diffstat (limited to 'dcimdirsort')
-rwxr-xr-x | dcimdirsort | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/dcimdirsort b/dcimdirsort new file mode 100755 index 0000000..5f5a7d1 --- /dev/null +++ b/dcimdirsort @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ -z "$1" ]; then + echo "Move files into a directory per day, based on file modification time" + echo "usage: $0 file1 file2 ..." + exit 0 +fi + +while [ ! -z "$1" ]; do + file="$1" + + file_date=`date -r "${file}" +"%Y-%m-%d"` + + if [ ! -d "${file_date}" ]; then + mkdir "${file_date}" + fi + + echo "Moving ${file} to ${file_date}/" + + mv "${file}" "${file_date}/" + + shift +done + |