Skip to content

Instantly share code, notes, and snippets.



Last active Nov 25, 2020
What would you like to do?
archive files based on creation date
archive() {
if [ ! -d "$1" ]; then echo Missing base; return 1; fi
local BASE=$1
for f in "${@:2:$#-1}"; do
if [ -d "$f" ]; then continue; fi;
local DATE=`date -r "$f" "+%Y-%m-%d"`
local YEAR=`date -r "$f" "+%Y"`
mkdir -p $TARGET_DIR
echo cp -iv "$f" "$TARGET_DIR/"
cp -iv "$f" "$TARGET_DIR/"
export -f archive
# $ yes n | archive ~/Desktop/msc/media /Volumes/H4N_SD/STEREO/**/*
# $ archive ~/archive myfile.wav
# > myfile.wav -> ~/archive/2020/2020-10-15/myfile.wav
# # $ archive ~/archive *

This comment has been minimized.

Copy link
Owner Author

@rchrd2 rchrd2 commented Oct 25, 2020

Looks like it's not working with files that have spaces in the names..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment