Sweeper idiot's guide

Thanks BH. Makes sense now as to regsub. Used rather than explicitly specifying the space as in my rule.
 
Indeed, but the "*" makes it match any number of spaces instead of having to specify a separate rule for each variation. If it were necessary to duplicate the rule for matching ":" or "_" (which does not apply here since one is in the title and the other is in the file name), one could use the regular expression "New[:_]\s*" - which would then match "New_" or "New_ " (etc), or "New:" or "New: " (etc) - always the longest string that matches.
 
Here's a patch to make the "Remove New: prefix" define both rules:
Code:
humax /mnt/hd2/mod/webif/plugin/sweeper # diff macro.js~ macro.js
--- macro.js~
+++ macro.js
@@ -41,6 +41,23 @@
  "cmd": "settitle",
  "arg": "%orig%regsub,New:\\s*,,"
  }
+  },
+  {
+  "raw": "filename New_* action {renamefile {%orig%regsub,New_\\s*,,}}",
+  "name": "Remove New_ prefix.",
+  "type": "global",
+  "enabled": "1",
+  "criteria": [
+  {
+  "negate": 0,
+  "cmd": "filename",
+  "arg": "New_*"
+  }
+  ],
+  "action": {
+  "cmd": "renamefile",
+  "arg": "%orig%regsub,New_\\s*,,"
+  }
  }
  ]
  },
 
Jeez. What's wrong with pasting a known working rule into sweeper. But I do notice that your code includes \\s* not just \s*
Presumably it makes a difference?
 
But I do notice that your code includes \\s* not just \s*
Presumably it makes a difference?
The escape character "\" has to be itself escaped in the shell commands. The shell will interpret the first "\" as an indicator that the next character must be treated differently, so if you were to only put the one "\" it would disappear in what got passed to the output (and probably wreck something else too). Thus "\\" says to the shell "this represents a single \ in the string", and just "\" gets passed to the output.

Passing special characters from process to process gets complicated.
 
I just think I'll take a nap 'till the F1 at 1700. VBA is good enough for me. But thanks for the explanation.
 
Oooh! It DID need more time. Thank you!

sweeper4.jpg

Revised idiot's guide:

1. In Package Management, install Sweeper
2. From the main screen, click on the broom icon
3. Click on TEXT EDITOR
4. Insert the following text:

# Remove New: prefix.
global title New:* action {settitle {%orig%regsub,New:\s*,,}}

# Remove New_ prefix
global filename New_* action {renamefile {%orig%regsub,New_\s*,,}}

5. Click on SAVE
6. Restart the Humax box
7. Wait a bit
 
I wouldn't use your date style, because after reformatting the recordings no longer sort in date sequence (this is the advantage of the "scientific" notation with the digits in order of decreasing significance). That's just personal preference of course, and these tools allow for expression of personal preference when the Humax SUI provides no alternative to the default. I'm pointing out the swing that goes with the roundabout.

It's the 'mericans I don't understand. Date format in order of decreasing significance: perfect, and it runs on to times as well. In order of increasing significance: I can live with that. But where the heck does MMDDYYYY come from???
 
I'm trying to to replace underscores with - in the following filename:

2015 11 10 - Humax HDR Fox T2 (humax) - Robot Wars.png

With this rule:

2015 11 10 - Humax HDR Fox T2 (humax) - Sweeper Rule Replace _.png

But I keep getting an error that the filename already exists.

What am I doing wrong?
 
I'm confused. My first reaction is that "-" is a reserved character you can't have in a file name, and yet you already seem to have one. The operating system (or maybe the Humax UI) substitutes underscores for reserved characters.
 
I can't be sure from the screenshot, but do you have a space after the _ in the regsub clause? If so, then it will not be matching and the replacement filename will be the same as the original. It would help if you could post the text version of the rule and the output from a test run (using the test button at the bottom of the screen).
 
This is the text version, I just borrowed this sweeper rule from the forum, this thread I believe.

# Remove _ from filename
global filename *_* action {renamefile {%orig%regsub,_ \s*, - ,}
 
Back
Top