Skip to content

Commit

Permalink
Merge pull request #8 from humdingerb/matchonce
Browse files Browse the repository at this point in the history
New release v1.1.0
  • Loading branch information
waddlesplash committed May 15, 2016
2 parents 44b9b08 + 5230e97 commit 6a73b47
Show file tree
Hide file tree
Showing 23 changed files with 284 additions and 207 deletions.
38 changes: 21 additions & 17 deletions documentation/Rule-Making Reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
</head>
<body>
<div align = "center">
<img width="64" height="64" src="./images/filer_icon_64.png" alt="Filer icon" />
<img src="./images/filer_icon_64.png" alt="Filer icon" />
<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> &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>
Expand All @@ -144,12 +144,15 @@ <h2>
<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 it to…</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 it to…</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 it to…</span></td><td></td><td>Rename the file. </td></tr>
<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>
<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>
<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>
<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.</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>
Expand All @@ -161,7 +164,7 @@ <h2>
<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 "Terminal Command" actions.</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. This is often useful for file archives or for pictures.</td></tr>
Expand Down Expand Up @@ -195,29 +198,30 @@ <h2>
<p>Move all e-mails on the MyAccount account to its own folder in the mail folder:</p>
<table>
<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>
<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>
<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>
</table>
</li><li>
<p>Sort JPEG photos by date into their own folder in /boot/home/Pictures:</p>
<table>
<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>
<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>
<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>
<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>
<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>
</table>
</li><li>
<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>
<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>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>
<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>
<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>
<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>
<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>
<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><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:</p>
<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>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>
<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>
<tr><td></td><td width="10"></td><td colspan="6"><span class="key">Move it to the Trash</span></td></tr>
<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>
<tr><td></td><td width="10"></td><td colspan="6"><span class="key">Move to Trash</span></td></tr>
</table>
</li>
</ul>
Expand Down
22 changes: 13 additions & 9 deletions documentation/User Documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
</head>
<body>
<div align = "center">
<img width="64" height="64" src="./images/filer_icon_64.png" alt="Filer icon" />
<img src="./images/filer_icon_64.png" alt="Filer icon" />
<p><span style="font-size: 1.5em; font-weight:bold">Filer's User Documentation</span></p>
<hr />
<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>
Expand Down Expand Up @@ -167,13 +167,15 @@ <h2>
<div align="center">
<img src="./images/filer_ruleslist.png" alt="Filer's rules" />
</div>
<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>
<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>
<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>
<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 />
Here's the window that opens to edit a rule:</p>
Here's the window that opens to edit a rule, which is similar to the one for adding a rule:</p>
<div align="center">
<img src="./images/filer_edit_rule.png" alt="Editing a rule" /></div>
<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>
<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>
<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 />
Conveniently, the text boxes support drag&amp;dropping of a file or folder.</p>
<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>

<h2>
Expand All @@ -185,7 +187,7 @@ <h2>
</div>

<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>
<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>
<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>

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

<p><b>1.1.0</b> - <i>05-05-2016</i></p>
<p><b>1.1.0</b> - <i>14-05-2016</i></p>
<ul>
<li>A new GUI that integrates Filer and AutoFiler settings.</li>
<li>Some usability improvements.</li>
<li>Change to the action names, rule settings have to be created anew.</li>
<li>Some usability improvements like drag&amp;drop support for AutoFiler folders and a tooltip for actions in the rule editing window.</li>
<li>Apply changed settings, rules and monitored folders live.</li>
<li>Add a button to manually start/stop AutoFiler.</li>
<li>Add a dropzone and make it replicatable.
<li>Add user documentation.</li></li>
<li>Add a dropzone and make it replicatable.</li>
<li>Add an option to stop matching rules after the first match was found (idea and code by Pete Goodeve).</li>
<li>Add user documentation.</li>
</ul>
</body>
</html>
Binary file modified documentation/images/filer_edit_rule.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/images/filer_icon_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/images/filer_ruleslist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified documentation/images/help.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 22 additions & 11 deletions sources/ActionView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
ActionView.cpp: View for adjusting settings for an individual Filer action
Written by DarkWyrm <[email protected]>, Copyright 2008
Released under the MIT license.
Contributed by: Pete Goodeve, 2016
*/

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

fValueBox = new AutoTextControl(rect, "valuebox", NULL, NULL,
new BMessage(MSG_VALUE_CHANGED), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
new BMessage(), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
AddChild(fValueBox);
fValueBox->SetDivider(0);

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

fValueBox->SetText("");
}

BString toolTip(
"\%FILENAME\%\t\t\tFull file name\n"
"\%EXTENSION\%\t\tJust the extension\n"
"\%BASENAME\%\t\tFile name without extension\n"
"\%FOLDER\%\t\t\tFull location of the folder which contains the file\n"
"\%FULLPATH\%\t\t\tFull location of the file\n"
"\%DATE\%\t\t\t\tCurrent date in the format MM-DD-YYYY\n"
"\%EURODATE\%\t\tCurrent date in the format DD-MM-YYYY\n"
"\%REVERSEDATE\%\t\tCurrent date in the format YYYY-MM-DD\n"
"\%TIME\%\t\t\t\tCurrent time using 24-hour time\n"
"\%ATTR:xxxx\%\t\t\tAn extended attribute of the file");
fValueBox->SetToolTip(toolTip.String());
}


Expand Down Expand Up @@ -112,7 +126,7 @@ ActionView::GetPreferredSize()
BRect rect(0.0, 0.0, 10.0, 10.0);

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

return rect;
}
Expand Down Expand Up @@ -143,15 +157,6 @@ ActionView::MessageReceived(BMessage* msg)
SetAction(name.String());
break;
}
case MSG_VALUE_CHANGED:
{
BString str;
if (fAction->FindString("value", &str) == B_OK)
fAction->ReplaceString("value", fValueBox->Text());
else
fAction->AddString("value", fValueBox->Text());
break;
}
default:
{
BView::MessageReceived(msg);
Expand All @@ -163,6 +168,12 @@ ActionView::MessageReceived(BMessage* msg)
BMessage*
ActionView::GetAction() const
{
BString str;
if (fAction->FindString("value", &str) == B_OK)
fAction->ReplaceString("value", fValueBox->Text());
else
fAction->AddString("value", fValueBox->Text());

return fAction;
}

Expand Down
2 changes: 1 addition & 1 deletion sources/AutoFilerTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ AutoFilerTab::_BuildLayout()
path.Append(gPrefsPath);

BNode node(path.Path());
bool autorun = true;
bool autorun = false;
if (node.InitCheck() == B_OK) {
bool tmpbool;
if (node.ReadAttr("autorun", B_BOOL_TYPE, 0, (void*)&tmpbool,
Expand Down
23 changes: 21 additions & 2 deletions sources/AutoTextControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@
AutoTextControl.cpp: A BTextControl which notifies on each keypress
Written by DarkWyrm <[email protected]>, Copyright 2007
Released under the MIT license.
Contributed by:
Pete Goodeve
*/

#include "AutoTextControl.h"
#include <Window.h>

#include <Entry.h>
#include <Path.h>
#include <PropertyInfo.h>
#include <String.h>
#include <Window.h>

#include <stdio.h>
#include <ctype.h>
#include <PropertyInfo.h>

static property_info sProperties[] = {
{ "CharacterLimit", { B_GET_PROPERTY, 0 }, { B_DIRECT_SPECIFIER, 0 },
Expand Down Expand Up @@ -118,6 +124,19 @@ AutoTextControl::DetachedFromWindow()
}


void
AutoTextControl::MessageReceived(BMessage* msg)
{
if (msg->WasDropped()) {
entry_ref r;
if (msg->FindRef("refs", &r) == B_OK)
SetText(BPath(&r).Path());
Invoke();
}
else BTextControl::MessageReceived(msg);
}


void
AutoTextControl::SetCharacterLimit(const uint32& limit)
{
Expand Down
3 changes: 3 additions & 0 deletions sources/AutoTextControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
AutoTextControl.h: A BTextControl which notifies on each keypress
Written by DarkWyrm <[email protected]>, Copyright 2007
Released under the MIT license.
Contributed by:
Pete Goodeve
*/

#ifndef AUTO_TEXT_CONTROL_H
Expand Down Expand Up @@ -44,6 +46,7 @@ class AutoTextControl : public BTextControl

virtual void AttachedToWindow();
virtual void DetachedFromWindow();
virtual void MessageReceived(BMessage* msg);

void SetFilter(AutoTextControlFilter* filter);
AutoTextControlFilter* GetFilter() { return fFilter; }
Expand Down
2 changes: 1 addition & 1 deletion sources/DropZoneTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ DropZone::MessageReceived(BMessage* msg)
"renames, copies or does all sorts of other things with them "
"according to rules created by the user.");
about->AddCopyright(2008, "DarkWyrm");
about->AddCopyright(2016, "Humdinger");
about->AddCopyright(2016, "Humdinger, Pete Goodeve");
about->Show();
}
default:
Expand Down
8 changes: 0 additions & 8 deletions sources/FSUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,6 @@ status_t CopyFile(BEntry* srcentry, BEntry* destentry, bool clobber)
command << "'" << srcstring << "' '" << deststring << "/'";
int code = system(command.String());

if (!code) {
entry_ref ref;
srcentry->GetRef(&ref);

deststring << "/" << ref.name;
return srcentry->SetTo(deststring.String());
}

return code;
}

Expand Down
3 changes: 1 addition & 2 deletions sources/FilerDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ static const char kSettingsFile[] = "Filer_settings";
#define MSG_SHOW_ADD_WINDOW 'shaw'
#define MSG_SHOW_EDIT_WINDOW 'shew'
#define MSG_REMOVE_RULE 'shrr'
#define MSG_REVERT 'rvrt'
#define MSG_RULE_SELECTED 'rlsl'
#define MSG_MOVE_RULE_UP 'mvup'
#define MSG_MOVE_RULE_DOWN 'mvdn'
#define MSG_MATCH_ONCE 'chon'

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

#define MSG_ACTION_CHOSEN 'tsch'
#define MSG_SHOW_ACTION_MENU 'sham'
#define MSG_VALUE_CHANGED 'vlch'

#define MSG_TEST_CHOSEN 'tsch'
#define MSG_MODE_CHOSEN 'mdch'
Expand Down
Loading

0 comments on commit 6a73b47

Please sign in to comment.