2024년 5월 17일 금요일

Mac에서 폴더 적용 스크립트를 활용하여 다운받은 파일을 정리하기

 다운로드 폴더에 들어오는 파일을 자동으로 정리하여봅니다.

[Cmd+Space] (=Spotlight) 한다음 스트립트편집기를 엽니다.


새로운 문서 만들기 창에서

사용자 폴더로 이동한다음 [Shift+Cmd+.]을 눌러 숨겨진 항목을 보이게합니다.

Library 폴더로 이동합니다.

Scripts 폴더로 이동합니다. 없으면 [MRB=마우스 오른쪽 버튼]하여 폴더를 생성해줍니다.

Folder Action Scripts 폴더로 이동합니다. 없으면 [MRB]하여 폴더를 생성해줍니다.

화면 아래쪽의 [새로운 폴더]버튼을 선택한 후 아래내용을 붙여넣기 합니다.



on adding folder items to this_folder after receiving added_items
repeat with the_item in added_items
tell application "Finder" to set {fType, nExt} to ({file type, name extension} of file the_item)
set the_folder to (path to downloads folder)
set the_sub_folder to "nil"
if (nExt is "pdf") then --파일의 확장자를 확인함
set the_sub_folder to "documents" --파일이 이동될 폴더의 이름을 설정함.
else if (nExt is "jpg") or (nExt is "jpeg") or (nExt is "png") or (nExt is "bmp") then
set the_sub_folder to "images"
else if (nExt is "dmg") or (nExt is "zip") then
set the_sub_folder to "dmgs"
else if (nExt is "torrent") then
set the_sub_folder to "torrents"
end if
--폴더가 생성이 되어있지 않은경우 폴더 생성함.
if not (the_sub_folder is equal to "nil") then
set the_target to POSIX path of the_folder & the_sub_folder
--for debug
--display dialog the_target
tell application "Finder"
if (exists folder the_sub_folder of the_folder) then
--for debug
--say "폴더 존재함"
else
make new folder at the_folder with properties {name:the_sub_folder}
--say "폴더 생성함"
end if
move the_item to POSIX file the_target with replacing
end tell
end if
end repeat
end adding folder items to

메뉴에서 [파일 > 저장...]한 다음 moveFiles.scpt로 저장해 줍니다.



스크립트 편집기를 종료합니다.
다운로드 폴더로 이동한다음 [MRB]한 후 
[폴더적용 스크립트 설정..]에서
방금전에 생성한 파일(moveFiles.scpt)를 선택합니다.
서비스 확인창이 뜨면 서비스실행을 선택합니다.

폴더적용 스크립트 창을 닫고 pdf, dmg, torrent등의 파일을 다른폴더에서 이동시키거나, 인터넷에서 파일을 다운받으면 파일이 자동으로 정리됩니다.







댓글 없음:

델파이 12.1이냐 11.3이냐?

 델파이가 12.1이 나왔습니다. 혹시 11.3버전의 커뮤니티버전이 필요하시는분이 있을 수 있을 것 같아 https://altd.embarcadero.com/.../RADStudio_11_3_esd_28... 와 이것 찾느랴 엄청고생함.