mybin

my ~/bin
git clone https://a3nm.net/git/mybin/
Log | Files | Refs | README

commit 94898f31173835e7279b014a14462880672ee7c2
parent 7f582b5074c8096d367506b51686ee9ed4357d2e
Author: Antoine Amarilli <a3nm@a3nm.net>
Date:   Wed,  7 Nov 2018 00:57:16 +0100

hierarchive

Diffstat:
hierarchive | 15+++++++++++++++
hierarchive_file | 8++++++++
2 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/hierarchive b/hierarchive @@ -0,0 +1,15 @@ +#!/bin/bash + +set -e + +# move old files from $1 to $2 +# expected usage: download/upload folder of a web browser, scratch folder, etc. + +NDAYS="7" + +D=$(date '+%Y-%m-%d') +F="$2/$D" +mkdir "$F" +cd "$1" +find -type f -mtime +$NDAYS -print0 | xargs -0 -n 1 hierarchive_file "$F" + diff --git a/hierarchive_file b/hierarchive_file @@ -0,0 +1,8 @@ +#!/bin/bash + +# move $2 to folder $1, creating any missing folders +D=$(dirname "$2") +mkdir -p "$1/$D" +mv "$2" "$1/$D" +#echo "HIERARCHIVE '$1' '$2'" +