Automator+Run Shell Script에서 날짜별로 폴더 파일 압축

2853 단어 AutomatorMacOSXBash

Create a workflow document and add "Run Shell Script" action from the left side pane.



Copy and past the code below.

while read file; do

    dir=`dirname "$file"`
    file_src=`basename "$file"`
    delimiter='_'
    timestamp=`date +%Y%m%d`-`date +%H%M%S`
    file_dst=$file_src$delimiter$timestamp

    /usr/local/bin/terminal-notifier -title "Archiver" -message "Start archiving "$file_src"."

    cd $dir
    cp -rfp ./$file_src ./$file_dst
    find ./$file_dst -name '*.DS_Store' -type f -delete
    zip -r9 $file_dst ./$file_dst
    rm -rf ./$file_dst

    /usr/local/bin/terminal-notifier -title "Archiver" -message $file_src" is now archived as "$file_dst"." -sound Glass

done

Activate the service from System Prefernces > Keyboard > Keyboard Shortcuts > Service Menu.


좋은 웹페이지 즐겨찾기