First of all, some rules I usually use, and then some useful rules and usage scenes.
- Download directory
- Tag the latest downloaded file: each downloaded file is tagged as the recently downloaded file, so that you can directly view the latest downloaded file through the tag in the Finder
- Label the files that have not been processed for more than 4 weeks - Red: if the download is successful and has been placed in the download directory for more than 4 weeks, tag them so that you can agree to deal with these files that have not been processed for more than 4 weeks
- Move the installation package to the app build new folder: for the newly downloaded app installation package, I am used to placing all the installation packages in a directory (~ / APP), and then create a directory with the same name to place the newly downloaded installation package and some configurations or plug-ins about the software
- Alfred workflow movement: the downloaded Alfred workflow is automatically moved to the corresponding directory (~ / app/alfred)
- Delete downloaded files 2 months ago: if the downloaded directory is not processed for more than 2 months, it will be deleted automatically
- Movies, music, pictures: automatically move to the corresponding directory
The above rules are relatively simple. Let's briefly talk about Rule 3. Rule 3 is implemented in conjunction with the Mac's own Automator. The implementation effects are as follows (I haven't finished the video for a long time):
The following are the specific implementation steps:
Step 1: create a workflow using Automator
Select workflow type
1
2
3
The focus is on the AppleScript script, which is mainly used to create a new folder with the same name, and move the APP installation package to the new directory. The specific implementation is as follows:
on run {input, parameters} if (count of input) < 3 then return --Get past time set filterTime to (item -2 of input) as number --Get target directory set targetFolder to (item -1 of input) --Pending documents set input to items 1 through -3 of input set output to {} repeat with temp in the input -- Loop traversal did not change the installation package file set anItem to temp as text set oneminutes to (current date) - filterTime * minutes tell application "System Events" to tell disk item anItem set relTargetPath to targetFolder --Specify directory set theContainer to targetFolder set {theName, theExtension, theFileDate} to {name, name extension, creation date} end tell --Filter creation time if theFileDate > oneminutes then if theExtension is in {"app", "dmg"} then --Software name set theName to text 1 thru -((count theExtension) + 2) of theName -- the name part --Determine whether a directory with the same name exists tell application "Finder" to set targetPathFileExists to exists folder ((targetFolder as text) & theName) --display dialog ((targetFolder & theName) as text) --display dialog ((targetPathFileExists) as text) if targetPathFileExists is true then set tempVar to display dialog "folder[" & theName & "] Already exists,Is moving" buttons {"yes", "no"} set theButtonPressed to button returned of tempVar if theButtonPressed = "yes" then tell application "Finder" move temp to (targetFolder as text) & theName display notification "Successfully moved to:" & POSIX path of ((targetFolder as text) & theName) with title ("file: " & theName as text) end tell end if else tell application "Finder" make new folder at folder theContainer with properties {name:theName} set end of output to result as alias move temp to result display notification "New directory successfully created" & theName & "And move the directory" & POSIX path of ((targetFolder as text) & theName) with title ("file: " & theName as text) end tell end if end if end if end repeat return output -- or output end run
Variable:
filterTime: the creation time of the installation package, in minutes; For example: 1, it means that the installation package will be moved in the last 1 minute
targetFolder: the directory path moved by the installation package, under which a directory with the same name will be created
Step 2: create Hazel rules
The rule here is very simple. Filter according to the downloaded file name. If the end of dmg is met, it indicates that it is an APP installation package, and then trigger the Automator workflow to create a new file with the same name and move the installation package
Automator CICD Consul Consul-template docker docker-compose elasticsearch gitlab gitlab-runner harbor Hazel hybris java kubernetes mac macx high efficiency nginx rancher spring boot spring cloud swarm Distributed serial number There are rules