Skip to content

Commit 6a73b47

Browse files
committed
Merge pull request #8 from humdingerb/matchonce
New release v1.1.0
2 parents 44b9b08 + 5230e97 commit 6a73b47

23 files changed

+284
-207
lines changed

documentation/Rule-Making Reference.html

+21-17
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
</head>
124124
<body>
125125
<div align = "center">
126-
<img width="64" height="64" src="./images/filer_icon_64.png" alt="Filer icon" />
126+
<img src="./images/filer_icon_64.png" alt="Filer icon" />
127127
<p><span style="font-size: 1.5em; font-weight:bold">Filer's Rule-Making Reference</span></p>
128128
<hr />
129129
<p id="index"><a href="#rule-conditions">Rule Conditions</a> &mdash; <a href="#rule-actions">Rule Actions</a> &mdash; <a href="#substitutions">Substitutions</a><br /><a href="#common-attributes">Common Attribute Names</a> &mdash; <a href="#examples">Example Rules</a></p>
@@ -144,12 +144,15 @@ <h2>
144144
<a id="rule-actions" name="rule-actions">Rule Actions</a></h2>
145145
<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>
146146
<table>
147-
<tr><td class="onelinetop"><span class="key">Move it to…</span></td><td width="10"></td><td>Move a file to the folder entered in the text field.</td></tr>
148-
<tr><td class="onelinetop"><span class="key">Copy it to…</span></td><td></td><td>Copy a file to the folder entered in the text field.</td></tr>
149-
<tr><td class="onelinetop"><span class="key">Rename it to…</span></td><td></td><td>Rename the file. </td></tr>
150-
<tr><td class="onelinetop"><span class="key">Move it to the Trash</span></td><td></td><td>For those files which you no longer want.</td></tr>
151-
<tr><td class="onelinetop"><span class="key">Delete it</span></td><td></td><td>Only if you're sure of yourself and hate a cluttered Trash can.</td></tr>
152-
<tr><td class="onelinetop"><span class="key">Terminal command…</span></td><td></td><td>For experts. 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 Terminal command actions or a shell script.</td></tr>
147+
<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>
148+
<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>
149+
<tr><td class="onelinetop"><span class="key">Rename to…</span></td><td></td><td>Rename the file.</td></tr>
150+
<tr><td class="onelinetop"><span class="key">Open</span></td><td></td><td>Open the file with its preferred application.</td></tr>
151+
<tr><td class="onelinetop"><span class="key">Add to archive…</span></td><td></td><td>Adds the file to a ZIP archive.</td></tr>
152+
<tr><td class="onelinetop"><span class="key">Move to Trash</span></td><td></td><td>Puts the file into the Trash.</td></tr>
153+
<tr><td class="onelinetop"><span class="key">Delete</span></td><td></td><td>By-passes the Trash and removes the file directly.</td></tr>
154+
<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>
155+
<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>
153156
</table>
154157

155158
<h2>
@@ -161,7 +164,7 @@ <h2>
161164
<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>
162165
<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>
163166
<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>
164-
<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 "Terminal Command" actions.</td></tr>
167+
<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>
165168
<tr><td class="onelinetop">%DATE%</td><td></td><td>Current date in the format MM-DD-YYYY.</td></tr>
166169
<tr><td class="onelinetop">%EURODATE%</td><td></td><td>Current date in the format DD-MM-YYYY.</td></tr>
167170
<tr><td class="onelinetop">%REVERSEDATE%</td><td></td><td>Current date in the format YYYY-MM-DD. This is often useful for file archives or for pictures.</td></tr>
@@ -195,29 +198,30 @@ <h2>
195198
<p>Move all e-mails on the MyAccount account to its own folder in the mail folder:</p>
196199
<table>
197200
<tr><td><i>When:</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>
198-
<tr><td><i>Do:</i></td><td width="10"></td><td><span class="key">Move it to</span></td><td width="10"></td><td colspan="3">/boot/home/mail/MyAccount</td></tr>
201+
<tr><td><i>Do:</i></td><td width="10"></td><td><span class="key">Move to folder</span></td><td width="10"></td><td colspan="3">/boot/home/mail/MyAccount</td></tr>
199202
</table>
200203
</li><li>
201204
<p>Sort JPEG photos by date into their own folder in /boot/home/Pictures:</p>
202205
<table>
203206
<tr><td><i>When:</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>
204-
<tr><td><i>Do:</i></td><td width="10"></td><td><span class="key">Rename it to…</span></td><td width="10"></td><td colspan="3">Photo %TIME%.jpg</td></tr>
205-
<tr><td></td><td width="10"></td><td><span class="key">Move it to</span></td><td width="10"></td><td colspan="3">/boot/home/Pictures/%DATE%</td></tr>
207+
<tr><td><i>Do:</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>
208+
<tr><td></td><td width="10"></td><td><span class="key">Move to folder</span></td><td width="10"></td><td colspan="3">/boot/home/Pictures/%DATE%</td></tr>
206209
</table>
207210
</li><li>
208211
<p>Make sure that MP3s have searchable attributes using Axel Dörfler's excellent id3attr program, rename them to "ArtistName - SongName.mp3", and sort them in the /boot/home/music folder by the artist's name. This would make importing an MP3 collection from somewhere else very easy.</p>
212+
<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>
209213
<table>
210214
<tr><td><i>When:</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>
211-
<tr><td><i>Do:</i></td><td width="10"></td><td class="onelinetop"><span class="key">Terminal command…</span></td><td width="10"></td><td colspan="3">id3attr '%FULLPATH%'</td></tr>
212-
<tr><td></td><td width="10"></td><td><span class="key">Rename it to…</span></td><td width="10"></td><td class="onelinetop" colspan="3">%ATTR:Audio:Artist% - %ATTR:Audio:Title%.mp3</td></tr>
213-
<tr><td></td><td width="10"></td><td><span class="key">Move it to</span></td><td width="10"></td><td colspan="3">/boot/home/music/%ATTR:Audio:Artist%</td></tr>
215+
<tr><td><i>Do:</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>
216+
<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>
217+
<tr><td></td><td width="10"></td><td><span class="key">Move to folder</span></td><td width="10"></td><td colspan="3">/boot/home/music/%ATTR:Audio:Artist%</td></tr>
214218
</table>
215219
</li><li>
216-
<p>Extract Zip archives to the Desktop and dump them into the Trash for later disposal:</p>
220+
<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>
217221
<table>
218222
<tr><td><i>When:</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>
219-
<tr><td><i>Do:</i></td><td width="10"></td><td class="onelinetop"><span class="key">Terminal command…</span></td><td width="10"></td><td class="onelinetop" colspan="3">unzip %FULLPATH% -d boot/home/Desktop</td></tr>
220-
<tr><td></td><td width="10"></td><td colspan="6"><span class="key">Move it to the Trash</span></td></tr>
223+
<tr><td><i>Do:</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>
224+
<tr><td></td><td width="10"></td><td colspan="6"><span class="key">Move to Trash</span></td></tr>
221225
</table>
222226
</li>
223227
</ul>

documentation/User Documentation.html

+13-9
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
</head>
126126
<body>
127127
<div align = "center">
128-
<img width="64" height="64" src="./images/filer_icon_64.png" alt="Filer icon" />
128+
<img src="./images/filer_icon_64.png" alt="Filer icon" />
129129
<p><span style="font-size: 1.5em; font-weight:bold">Filer's User Documentation</span></p>
130130
<hr />
131131
<p id="index"><a href="#usage">Usage</a> &mdash; <a href="#dropzone">Dropzone</a> &mdash; <a href="#rules">Rules</a> &mdash; <a href="#autofiler">AutoFiler</a> &mdash; <a href="#help">Help</a> &mdash; <a href="#history">History</a></p>
@@ -167,13 +167,15 @@ <h2>
167167
<div align="center">
168168
<img src="./images/filer_ruleslist.png" alt="Filer's rules" />
169169
</div>
170-
<p>The second tab shows the list of organization rules. Every dropped file is being tested against &ndash; and if its type etc. matches processed by &ndash; each rule, top to bottom.</p>
170+
<p>The second tab shows the list of organization rules. Every dropped file is being tested against &ndash; and if its type etc. matches, processed by &ndash; each rule, top to bottom.</p>
171+
<p>You can opt to <span class="menu">Apply only the first matching rule</span> if you prefer that. Filer will then stop trying to match rules to a file after it found one. (A rule can override that by adding a <span class="menu">Continue</span> in its "Do" block. See the <a href="Rule-Making%20Reference.html">Rule-Making Reference</a> for more info.)</p>
171172
<p>You can arrange the rules with the <span class="button">Move up/down</span> buttons and <span class="button">Add…</span>, <span class="button">Edit…</span> and <span class="button">Remove</span> them.<br />
172-
Here's the window that opens to edit a rule:</p>
173+
Here's the window that opens to edit a rule, which is similar to the one for adding a rule:</p>
173174
<div align="center">
174175
<img src="./images/filer_edit_rule.png" alt="Editing a rule" /></div>
175176
<p>A rule needs three items: A <span class="menu">Description</span>, the condition <span class="menu">When</span> it is applied, and what action to <span class="menu">Do</span>.</p>
176-
<p>Click on the buttons in the "When" and "Do" boxes to explore the various options to construct the right condition and what action will be taken. You can add several conditions which will <i>all</i> have to be met to trigger the action. If you add several actions in the "Do" box, be aware that they are executed in order, from top to bottom.</p>
177+
<p>Click on the buttons in the "When" and "Do" boxes to explore the various options to construct the right condition and what action will be taken. You can add several conditions which will <i>all</i> have to be met to trigger the action. If you add several actions in the "Do" box, be aware that they are executed in order, from top to bottom.<br />
178+
Conveniently, the text boxes support drag&amp;dropping of a file or folder.</p>
177179
<p>Please read the <a href="Rule-Making%20Reference.html">Rule-Making Reference</a> (also available from the <span class="button">Help…</span> button) for more information on the various possibilities.</p>
178180

179181
<h2>
@@ -185,7 +187,7 @@ <h2>
185187
</div>
186188

187189
<p>The <i>AutoFiler</i> itself is a background application. You can activate the checkbox at the top to automatically <span class="menu">Run AutoFiler on system startup</span>. The button to beside it lets you start/stop it manually.</p>
188-
<p>You can <span class="button">Add…</span>, <span class="button">Edit…</span> and <span class="button">Remove</span> the folders that <i>AutoFiler</i> will monitor for incoming files.</p>
190+
<p>You can <span class="button">Add…</span>, <span class="button">Edit…</span> and <span class="button">Remove</span> the folders that <i>AutoFiler</i> will monitor for incoming files. One or more folders are quickly added via drag&amp;drop.</p>
189191

190192
<h2>
191193
<a href="#"><img src="images/up.png" style="border:none;float:right" alt="index" /></a>
@@ -203,14 +205,16 @@ <h2>
203205
<li>Initial release.</li>
204206
</ul>
205207

206-
<p><b>1.1.0</b> - <i>05-05-2016</i></p>
208+
<p><b>1.1.0</b> - <i>14-05-2016</i></p>
207209
<ul>
208210
<li>A new GUI that integrates Filer and AutoFiler settings.</li>
209-
<li>Some usability improvements.</li>
211+
<li>Change to the action names, rule settings have to be created anew.</li>
212+
<li>Some usability improvements like drag&amp;drop support for AutoFiler folders and a tooltip for actions in the rule editing window.</li>
210213
<li>Apply changed settings, rules and monitored folders live.</li>
211214
<li>Add a button to manually start/stop AutoFiler.</li>
212-
<li>Add a dropzone and make it replicatable.
213-
<li>Add user documentation.</li></li>
215+
<li>Add a dropzone and make it replicatable.</li>
216+
<li>Add an option to stop matching rules after the first match was found (idea and code by Pete Goodeve).</li>
217+
<li>Add user documentation.</li>
214218
</ul>
215219
</body>
216220
</html>
139 Bytes
Loading
3.09 KB
Loading
839 Bytes
Loading

documentation/images/help.png

278 Bytes
Loading

sources/ActionView.cpp

+22-11
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
ActionView.cpp: View for adjusting settings for an individual Filer action
33
Written by DarkWyrm <[email protected]>, Copyright 2008
44
Released under the MIT license.
5+
Contributed by: Pete Goodeve, 2016
56
*/
67

78
#include <Font.h>
@@ -47,7 +48,7 @@ ActionView::ActionView(const BRect& frame, const char* name, BMessage* action,
4748
rect.right = rect.left + 10;
4849

4950
fValueBox = new AutoTextControl(rect, "valuebox", NULL, NULL,
50-
new BMessage(MSG_VALUE_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
51+
new BMessage(), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
5152
AddChild(fValueBox);
5253
fValueBox->SetDivider(0);
5354

@@ -80,6 +81,19 @@ ActionView::ActionView(const BRect& frame, const char* name, BMessage* action,
8081

8182
fValueBox->SetText("");
8283
}
84+
85+
BString toolTip(
86+
"\%FILENAME\%\t\t\tFull file name\n"
87+
"\%EXTENSION\%\t\tJust the extension\n"
88+
"\%BASENAME\%\t\tFile name without extension\n"
89+
"\%FOLDER\%\t\t\tFull location of the folder which contains the file\n"
90+
"\%FULLPATH\%\t\t\tFull location of the file\n"
91+
"\%DATE\%\t\t\t\tCurrent date in the format MM-DD-YYYY\n"
92+
"\%EURODATE\%\t\tCurrent date in the format DD-MM-YYYY\n"
93+
"\%REVERSEDATE\%\t\tCurrent date in the format YYYY-MM-DD\n"
94+
"\%TIME\%\t\t\t\tCurrent time using 24-hour time\n"
95+
"\%ATTR:xxxx\%\t\t\tAn extended attribute of the file");
96+
fValueBox->SetToolTip(toolTip.String());
8397
}
8498

8599

@@ -112,7 +126,7 @@ ActionView::GetPreferredSize()
112126
BRect rect(0.0, 0.0, 10.0, 10.0);
113127

114128
rect.bottom = fActionButton->Frame().Height();
115-
rect.right = StringWidth("Move it to the Trash") + 5.0 + 100;
129+
rect.right = StringWidth("Shell command…") + 5.0 + 100;
116130

117131
return rect;
118132
}
@@ -143,15 +157,6 @@ ActionView::MessageReceived(BMessage* msg)
143157
SetAction(name.String());
144158
break;
145159
}
146-
case MSG_VALUE_CHANGED:
147-
{
148-
BString str;
149-
if (fAction->FindString("value", &str) == B_OK)
150-
fAction->ReplaceString("value", fValueBox->Text());
151-
else
152-
fAction->AddString("value", fValueBox->Text());
153-
break;
154-
}
155160
default:
156161
{
157162
BView::MessageReceived(msg);
@@ -163,6 +168,12 @@ ActionView::MessageReceived(BMessage* msg)
163168
BMessage*
164169
ActionView::GetAction() const
165170
{
171+
BString str;
172+
if (fAction->FindString("value", &str) == B_OK)
173+
fAction->ReplaceString("value", fValueBox->Text());
174+
else
175+
fAction->AddString("value", fValueBox->Text());
176+
166177
return fAction;
167178
}
168179

sources/AutoFilerTab.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ AutoFilerTab::_BuildLayout()
8787
path.Append(gPrefsPath);
8888

8989
BNode node(path.Path());
90-
bool autorun = true;
90+
bool autorun = false;
9191
if (node.InitCheck() == B_OK) {
9292
bool tmpbool;
9393
if (node.ReadAttr("autorun", B_BOOL_TYPE, 0, (void*)&tmpbool,

sources/AutoTextControl.cpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
AutoTextControl.cpp: A BTextControl which notifies on each keypress
33
Written by DarkWyrm <[email protected]>, Copyright 2007
44
Released under the MIT license.
5+
Contributed by:
6+
Pete Goodeve
57
*/
68

79
#include "AutoTextControl.h"
8-
#include <Window.h>
10+
11+
#include <Entry.h>
12+
#include <Path.h>
13+
#include <PropertyInfo.h>
914
#include <String.h>
15+
#include <Window.h>
16+
1017
#include <stdio.h>
1118
#include <ctype.h>
12-
#include <PropertyInfo.h>
1319

1420
static property_info sProperties[] = {
1521
{ "CharacterLimit", { B_GET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 },
@@ -118,6 +124,19 @@ AutoTextControl::DetachedFromWindow()
118124
}
119125

120126

127+
void
128+
AutoTextControl::MessageReceived(BMessage* msg)
129+
{
130+
if (msg->WasDropped()) {
131+
entry_ref r;
132+
if (msg->FindRef("refs", &r) == B_OK)
133+
SetText(BPath(&r).Path());
134+
Invoke();
135+
}
136+
else BTextControl::MessageReceived(msg);
137+
}
138+
139+
121140
void
122141
AutoTextControl::SetCharacterLimit(const uint32& limit)
123142
{

sources/AutoTextControl.h

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
AutoTextControl.h: A BTextControl which notifies on each keypress
33
Written by DarkWyrm <[email protected]>, Copyright 2007
44
Released under the MIT license.
5+
Contributed by:
6+
Pete Goodeve
57
*/
68

79
#ifndef AUTO_TEXT_CONTROL_H
@@ -44,6 +46,7 @@ class AutoTextControl : public BTextControl
4446

4547
virtual void AttachedToWindow();
4648
virtual void DetachedFromWindow();
49+
virtual void MessageReceived(BMessage* msg);
4750

4851
void SetFilter(AutoTextControlFilter* filter);
4952
AutoTextControlFilter* GetFilter() { return fFilter; }

sources/DropZoneTab.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ DropZone::MessageReceived(BMessage* msg)
171171
"renames, copies or does all sorts of other things with them "
172172
"according to rules created by the user.");
173173
about->AddCopyright(2008, "DarkWyrm");
174-
about->AddCopyright(2016, "Humdinger");
174+
about->AddCopyright(2016, "Humdinger, Pete Goodeve");
175175
about->Show();
176176
}
177177
default:

sources/FSUtils.cpp

-8
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,6 @@ status_t CopyFile(BEntry* srcentry, BEntry* destentry, bool clobber)
125125
command << "'" << srcstring << "' '" << deststring << "/'";
126126
int code = system(command.String());
127127

128-
if (!code) {
129-
entry_ref ref;
130-
srcentry->GetRef(&ref);
131-
132-
deststring << "/" << ref.name;
133-
return srcentry->SetTo(deststring.String());
134-
}
135-
136128
return code;
137129
}
138130

sources/FilerDefs.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ static const char kSettingsFile[] = "Filer_settings";
3535
#define MSG_SHOW_ADD_WINDOW 'shaw'
3636
#define MSG_SHOW_EDIT_WINDOW 'shew'
3737
#define MSG_REMOVE_RULE 'shrr'
38-
#define MSG_REVERT 'rvrt'
3938
#define MSG_RULE_SELECTED 'rlsl'
4039
#define MSG_MOVE_RULE_UP 'mvup'
4140
#define MSG_MOVE_RULE_DOWN 'mvdn'
41+
#define MSG_MATCH_ONCE 'chon'
4242

4343
#define MSG_STARTSTOP_AUTOFILER 'ssaf'
4444
#define MSG_AUTOFILER_AUTORUN 'afas'
@@ -52,7 +52,6 @@ static const char kSettingsFile[] = "Filer_settings";
5252

5353
#define MSG_ACTION_CHOSEN 'tsch'
5454
#define MSG_SHOW_ACTION_MENU 'sham'
55-
#define MSG_VALUE_CHANGED 'vlch'
5655

5756
#define MSG_TEST_CHOSEN 'tsch'
5857
#define MSG_MODE_CHOSEN 'mdch'

0 commit comments

Comments
 (0)