forked from HaikuArchives/Filer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rule-Making Reference.html
236 lines (226 loc) · 13.3 KB
/
Rule-Making Reference.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US" xml:lang="en-US">
<head>
<!--
* Copyright 2016-2017
* Distributed under the terms of the MIT License.
*
* Authors:
* DarkWyrm <[email protected]>
* Humdinger <[email protected]>
-->
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="robots" content="all" />
<title>Filer's Rule-Making Reference</title>
<style type="text/css">
body {
font-size: 0.9em;
font-family: "DejaVu Sans",Arial,Helvetica,sans-serif;
line-height: 1.5;
margin: 40px;
min-width: 45em;
max-width: 70em;
}
/* link colors and text decoration */
a:link {
font-weight: bold;
text-decoration: none;
color: #dc3c01;
}
a:visited {
font-weight: bold;
text-decoration: none;
color: #892601;
}
a:hover, a:active {
text-decoration: underline;
color: #ff4500;
}
hr {
border: dotted thin #e0e0e0;
}
h1 {
font-size: 1.3em;
border-bottom: dotted thin #e0e0e0;
margin-bottom: 45px;
}
h2 {
font-size: 1.2em;
border-bottom: dotted thin #e0e0e0;
margin-top: 40px;
}
h3 {
font-size: 1em;
border-bottom: none;
margin-bottom: 0px;
}
.key { /* Shortcut (separate with   */
-webkit-border-radius: 3px;
-khtml-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
border-color: #c7c7c7;
border-style: solid;
border-width: 1px;
padding: 0px 2px 0px 2px;
background-color: #e8e8e8;
font-family: sans;
font-variant: small-caps;
font-size: 1em;
}
.menu { /* Menu */
font-size: 1.0em;
font-family: serif;
font-style: italic;
color: #24225e;
}
.button { /* Button */
font-size: 1.0em;
font-family: serif;
font-style: italic;
color: #33583c;
}
.path { /* File path */
background-color: #e8e8e8;
font-size: 0.9em;
font-family: monospace;
}
td.onelinetop {
vertical-align: top;
white-space: nowrap;
}
ul {
padding-left: 14px;
}
/* Rounded corner boxes */
/* Common declarations */
.box-info {
-webkit-border-radius: 10px;
-khtml-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
border-style: dotted;
border-width: thin;
border-color: #dcdcdc;
padding: 10px 15px 10px 80px;
margin-bottom: 15px;
margin-top: 15px;
min-height: 42px;
}
.box-info {
background: #e4ffde url(images/alert_info_32.png) 15px 15px no-repeat;
}
</style>
</head>
<body>
<div align = "center">
<a href="https://github.com/HaikuArchives/Filer">
<img src="./images/filer_icon_64.png" alt="Filer icon" /></a>
<p><span style="font-size: 1.5em; font-weight:bold">Filer's Rule-Making Reference</span></p>
<hr />
<p id="index"><a href="#rule-conditions">Rule Conditions</a> — <a href="#rule-actions">Rule Actions</a> — <a href="#substitutions">Substitutions</a><br /><a href="#common-attributes">Common Attribute Names</a> — <a href="#examples">Example Rules</a></p>
</div>
<hr />
<p><br /></p>
<p>You will probably find most parts of the Filer pretty self-explanatory, please refer to <a href="User%20Documentation.html">Filer's User Documentation</a> for more information.<br />
To really get power out of it, you'll want to read the information below, though. There are also a number of useful examples to get you going.</p>
<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="rule-conditions" name="rule-conditions">Rule Conditions</a></h2>
<p>You will need at least one condition for the rule to test for. It can be the type of file, something about its name, how big it is, or some other attribute. These other attributes can be things like someone's nickname kept in a Person file or the e-mail address in the To: field of an e-mail. Note that these can appear on just about any kind of file, but generally will only be found on the kind of file you expect it to be on. A rule will only match if all the conditions you set are met.</p>
<div class="box-info">If a rule doesn't work right, try running Filer from the Terminal to see what it's doing as it processes your files.</div>
<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="rule-actions" name="rule-actions">Rule Actions</a></h2>
<p>If the conditions are met, the Filer will perform a series of actions that you choose. Actions can be chained together, such as renaming a file and then moving it to another folder.</p>
<table>
<tr><td class="onelinetop"><span class="key">Move to folder</span></td><td width="10"></td><td>Move a file to the folder entered in the text field.</td></tr>
<tr><td class="onelinetop"><span class="key">Copy to folder</span></td><td></td><td>Copy a file to the folder entered in the text field.</td></tr>
<tr><td class="onelinetop"><span class="key">Rename to</span></td><td></td><td>Rename the file.</td></tr>
<tr><td class="onelinetop"><span class="key">Open</span></td><td></td><td>Open the file with its preferred application.</td></tr>
<tr><td class="onelinetop"><span class="key">Add to archive</span></td><td></td><td>Adds the file to a ZIP archive. You can specify:
<ul>
<li>an existing folder: The archive will be created in that folder and is named like the file with an added '.zip' suffix.</li>
<li>an archive file name: The file will be added to that archive.</li>
</ul>
<p>If an archive already exists, the file will be added to it (replacing a similarly named file in the archive, if it's newer).<br />
The used commandline is <tt>zip -9yur</tt>.</p></td></tr>
<tr><td class="onelinetop"><span class="key">Move to Trash</span></td><td></td><td>Puts the file into the Trash.</td></tr>
<tr><td class="onelinetop"><span class="key">Delete</span></td><td></td><td>By-passes the Trash and removes the file directly.</td></tr>
<tr><td class="onelinetop"><span class="key">Shell command</span></td><td></td><td>Run a command just as if you typed it into a Terminal. Substitutions (see below) are performed before the command is executed. This can make the Filer automatically do all sorts of things it couldn't do otherwise. If you move or rename the file this way, you'll need to do everything else with more shell command actions or a script, because the following actions/rules can't keep track of these changes.</td></tr>
<tr><td class="onelinetop"><span class="key">Continue</span></td><td></td><td>If you've set <span class="menu">Apply only the first matching rule</span> in the rules settings, this "<i>Continue</i>" will override it, and the matching of rules will continue anyway.</td></tr>
</table>
<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="substitutions" name="substitutions">Substitutions</a></h2>
<p>You can also substitute certain information about the file into the text box for an action. For example: %TIME% is replaced with the current time before the action is performed. Here are all the possible choices:</p>
<table>
<tr><td class="onelinetop">%FILENAME%</td><td width="10"></td><td>Full name of the file being processed.</td></tr>
<tr><td class="onelinetop">%EXTENSION%</td><td></td><td>Just the extension of the file, as in <span class="path">.txt</span> in <span class="path">MyTextFile.txt</span> or <span class="path">.tar.gz</span> in <span class="path">MyArchive.tar.gz</span>.</td></tr>
<tr><td class="onelinetop">%BASENAME%</td><td></td><td>File name without extension, like <span class="path">MyTextFile</span> in <span class="path">MyTextFile.txt</span>.</td></tr>
<tr><td class="onelinetop">%FOLDER%</td><td></td><td>Full location of the folder which contains the file, like <span class="path">/boot/home/Videos</span> for <span class="path">/boot/home/Videos/HaikuRocks.wmv</span>.</td></tr>
<tr><td class="onelinetop">%FULLPATH%</td><td></td><td>Full location of the file, such as <span class="path">/boot/home/config/MyFavoriteSong.mp3</span>. You'll need this for "Shell command" actions.</td></tr>
<tr><td class="onelinetop">%DATE%</td><td></td><td>Current date in the format MM-DD-YYYY.</td></tr>
<tr><td class="onelinetop">%EURODATE%</td><td></td><td>Current date in the format DD-MM-YYYY.</td></tr>
<tr><td class="onelinetop">%REVERSEDATE%</td><td></td><td>Current date in the format YYYY-MM-DD (international standard <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>). This is often useful for file archives or for pictures.</td></tr>
<tr><td class="onelinetop">%TIME%</td><td></td><td>Current time using 24-hour time.</td></tr>
<tr><td class="onelinetop">%ATTR:xxxx%</td><td></td><td>An extended attribute of the file. The technical name for the attribute is put between the colon and the second %. At this point, unfortunately, the case-sensitive, technical name of the attribute must be used. For example, an e-mail address attribute is META:email. This can be found in the FileTypes preferences application by choosing the type of file it is normally found on and double-clicking on it in the "Extra attributes" box. In the window that appears, it will be in the box marked "Internal name".</td></tr>
</table>
<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="common-attributes" name="common-attributes">Common Attributes</a></h2>
<p>Here's a list of some common attributes. Consult the FileTypes preferences if you look for the attribute name of a specific file type.</p>
<table>
<tr><td></td><td width="10"></td><td><b>Attribute name</b></td></tr>
<tr><td>E-mail address</td><td></td><td>MAIL:email</td></tr>
<tr><td>E-mail subject</td><td></td><td>MAIL:subject</td></tr>
<tr><td>E-mail recipient</td><td></td><td>MAIL:to</td></tr>
<tr><td>E-mail sender</td><td></td><td>MAIL:from</td></tr>
<tr><td>E-Mail spam/genuine</td><td></td><td>MAIL:classification</td></tr>
<tr><td>Nickname</td><td></td><td>META:nickname</td></tr>
<tr><td>Street address</td><td></td><td>META:address</td></tr>
<tr><td>MP3 artist</td><td></td><td>Audio:Artist</td></tr>
<tr><td>MP3 album</td><td></td><td>Audio:Album</td></tr>
<tr><td>MP3 track name</td><td></td><td>Audio:Title</td></tr>
<tr><td>Program category</td><td></td><td>META:category</td></tr>
</table>
<h2>
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
<a id="examples" name="examples">Example Rules</a></h2>
<ul>
<li>
<p>Move all e-mails on the MyAccount account to its own folder in the mail folder:</p>
<table>
<tr><td><i>If:</i></td><td width="10"></td><td><span class="key">Email:Account</span></td><td width="10"></td><td><span class="key">is</span></td><td width="10"></td><td>MyAccount</td></tr>
<tr><td><i>Then:</i></td><td width="10"></td><td class="onelinetop"><span class="key">Move to folder</span></td><td width="10"></td><td colspan="3">/boot/home/mail/MyAccount</td></tr>
</table>
</li><li>
<p>Sort JPEG photos by date into their own folder in <span class="path">/boot/home/Pictures</span>:</p>
<table>
<tr><td><i>If:</i></td><td width="10"></td><td><span class="key">Type</span></td><td width="10"></td><td><span class="key">is</span></td><td width="10"></td><td>image/jpeg</td></tr>
<tr><td><i>Then:</i></td><td width="10"></td><td><span class="key">Rename to</span></td><td width="10"></td><td colspan="3">Photo %TIME%.jpg</td></tr>
<tr><td></td><td width="10"></td><td class="onelinetop"><span class="key">Move to folder</span></td><td width="10"></td><td colspan="3">/boot/home/Pictures/%DATE%</td></tr>
</table>
</li><li>
<p>Make sure that MP3s have searchable attributes using Axel Dörfler's excellent <tt>id3attr</tt> program, rename them to "ArtistName - SongName.mp3", and sort them in the <span class="path">/boot/home/Music</span> folder by the artist's name. This would make importing an MP3 collection from somewhere else very easy.</p>
<p><b>Note when using shell commands:</b> Take care to 'escape' the variable, here <tt>'%FULLPATH%'</tt>. The inverted commas make sure spaces and other special characters don't spoil the fun.</p>
<table>
<tr><td><i>If:</i></td><td width="10"></td><td><span class="key">Name</span></td><td width="10"></td><td class="onelinetop" width="20"><span class="key">ends with</span></td><td width="10"></td><td>.mp3</td></tr>
<tr><td><i>Then:</i></td><td width="10"></td><td class="onelinetop"><span class="key">Shell command</span></td><td width="10"></td><td colspan="3">id3attr '%FULLPATH%'</td></tr>
<tr><td></td><td width="10"></td><td><span class="key">Rename to</span></td><td width="10"></td><td class="onelinetop" colspan="3">%ATTR:Audio:Artist% - %ATTR:Audio:Title%.mp3</td></tr>
<tr><td></td><td width="10"></td><td class="onelinetop"><span class="key">Move to folder</span></td><td width="10"></td><td colspan="3">/boot/home/Music/%ATTR:Audio:Artist%</td></tr>
</table>
</li><li>
<p>Extract Zip archives to the Desktop and dump them into the Trash for later disposal. Again, mind the 'escaped' variable '%FULLPATH%' in the shell command!</p>
<table>
<tr><td><i>If:</i></td><td width="10"></td><td><span class="key">Name</span></td><td width="10"></td><td class="onelinetop" width="20"><span class="key">ends with</span></td><td width="10"></td><td>.zip</td></tr>
<tr><td><i>Then:</i></td><td width="10"></td><td class="onelinetop"><span class="key">Shell command</span></td><td width="10"></td><td class="onelinetop" colspan="3">unzip '%FULLPATH%' -d boot/home/Desktop</td></tr>
<tr><td></td><td width="10"></td><td colspan="6"><span class="key">Move to Trash</span></td></tr>
</table>
</li>
</ul>
</body>
</html>