dated_download_folder.sh

#!/bin/bash CURRENT=$HOME"/Downloads/" DATE_TODAY=$(date '+%Y-%m-%d') NEWPATH="$CURRENT$DATE_TODAY/" DEBUG=true # create dated folder if [[ -z $(find "$CURRENT" -name "$DATE_TODAY") ]] then # not find => -z mkdir "$CURRENT$DATE_TODAY" fi # find files in the root folder and move them find "$CURRENT" -type f -maxdepth 1 ! -iname ".DS_Store" ! -iname "*.download" -print | while read x; do filename=$(basename "$x") NPFile="$NEWPATH$filename" if [ -f "$NPFile" ]; then #echo mv "$x" "$NPFile".backup mv "$x" "${NPFile%.*} copy.${NPFile##*.}" else mv "$x" "$NPFile" fi done # move files older than two weeks into the trash find "$CURRENT" -maxdepth 1 -type d -mtime +14 -print | while read file; do osascript -e "tell application \"Finder\" to delete POSIX file \"${file}\"" done
Dated download folder for macOS - 2020

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.