Page 1 of 1

A couple of scripts I need, please help

Posted: 29 Nov 2012 22:35
by Zephyr
First is not really a script, I just need to know how I can see all except certain folders based on the color filter. I have a blue color filter for some folders and I want to only see the folders that are blue. Or at least sort by color, but restricting the view is preferable. I have something like this to only show mp3 files, but idk how to restrict to a color.

Second, is there a way to restrict the view to anything modified a certain amount of days ago?

Third is a script question. Let's say I have a couple of mp3 files with two different artists tagged in the metadata.

Blue Stahli - Ultranumb
Andy Harding - Pajass

I want the script to go through all the mp3 files in the folder I'm in and create folders for them by the name of the artist, and place them in that folder. So for example if I have a folder called Music and in there are the two songs I mentioned above, the script would copy Ultranumb into a new Blue Stahli folder it creates, and copy Pajass into a new andy harding folder it created. This is based on the artist information you can find in the properties of the files.

I hope it's possible :)

EDIT:

Actually there's something else that would be cool.


Music
-------------------------
Folder 1 - Song 1, Song 2
Folder 2 - Song 1, Song 2, Song 3
Folder 3 - Song 1

I want to delete Folder 1, 2, and 3, and put the songs in the Music folder which is the parent of these folders.

So I'd basically need a script that goes into each folder and takes the files out, deletes them, then puts the music in the parent folder.

Re: A couple of scripts I need, please help

Posted: 29 Nov 2012 23:09
by highend
Views per color aren't possible afaik, because the filter() command doesn't support colors. It would be a very strong feature if this would be implemented. Btw, tags as a filter criteria would be nice as well. Maybe that's something for the feature request section of the forum?

Script for moving mp3's from the current folder to a folder with the artist name of each file:

Code: Select all

	setting('BackgroundFileOps', 0);
	foreach($file, formatlist(folderreport("files", "r"), "ef", "<crlf>", "*.mp3"), "<crlf>") {
		moveto "<curpath>\" . property("#20", $file), $file, , 2;
	}

Script for moving mp3 files out of subfolders to current folder (and NO, it won't delete your directories). Do this by hand afterwards. Way to dangerous, if you've left anything important there...

Code: Select all

	setting('BackgroundFileOps', 0);
	$files = folderreport("files", "r", , "r");
	foreach($file, formatlist($files, "ef", "<crlf>", "*.mp3"), "<crlf>") {
		moveto "<curpath>", $file, , 2;
	}
	text "These are files, that still exist after moving:<br><br>" . formatlist($files, "ef", "<crlf>", "!*.mp3");

Re: A couple of scripts I need, please help

Posted: 30 Nov 2012 02:18
by Zephyr
Hmm, that's kind of shocking to me. However, since colors filter based on certain attributes, I could get around that by copying the criteria I use for color and use it in a script.

Is there a way to, script or no script, restrict the view to folders or files that are 1-2 days old?

Re: A couple of scripts I need, please help

Posted: 30 Nov 2012 08:27
by FluxTorpedoe
Hi'
I don't know if that's what you're looking for (i.e. if by "color" you mean "color labels").

This is just an excerpt of a custom button I use (which has even more filters), so I post it as is, I didn't try to optimize it.
It offers filtering by:
- color labels
- modified dates (hours, days)
- created dates
- size

Notes:
• The first "Filter Labeled Items" has two functions:
- if no item (or a non labeled item) is selected, then it will filter the view to only show all labeled items
- if a labeled item is selected, then it will filter the view to only show same-label items
-> if you want to filter only specific labels, you can change or add selfilter lines. For example, I left the one I use with "(" (my main color labels have parenthesis in their name), and I added the second selfilter with "e" (by default, all color label names contain "e").
• By personal preference, the "Filter Modified..." or "Filter Created..." are based on hours - so "Modified Today" means "during the last 24 hours".
• Change the icons to the ones that suit you.
Though if that may be of interest to some, I could post my full "Filter" button with working generic icons.

Hope you enjoy it, 8)
Flux


---------

Code: Select all

"Filter Labeled Items|:findlabel"
  $mylabel=report("{Label}", 1);
  if (get('CountSelected') != 1) || !($mylabel) {
    selfilter "(", , "Label"; selfilter "e", , "Label", 1;
  } else {
    selfilter $mylabel, , "Label";
  }
  if (get('CountSelected') != 0) {
    #359;
    #251;
    status("LABEL [".$mylabel."] items filtered");
  } else {
    status("No LABELED items to filter", "883333", stop);
  }

-

"Filter Modified Today|[Icons]\Date.ico"
  global $g_myhours; $g_myhours=24;
  sub "_Filter Modified";
"Filter Modified The Last 3 Days"
  global $g_myhours; $g_myhours=72;
  sub "_Filter Modified";
"Filter Modified This Week"
  global $g_myhours; $g_myhours=168;
  sub "_Filter Modified";
"Filter Modified The Last 6 Hours"
  global $g_myhours; $g_myhours=6;
  sub "_Filter Modified";
"Filter Size > 100 MB|[Icons]\Size.ico"
  global $g_mysize; $g_mysize=100;
  sub "_Filter Size";
"Filter Size > 10 MB"
  global $g_mysize; $g_mysize=10;
  sub "_Filter Size";

-

"Filter Created Today|[Icons]\Date.ico"
  global $g_myhours; $g_myhours=24;
  sub "_Filter Created";
"Filter Created This Week"
  global $g_myhours; $g_myhours=168;
  sub "_Filter Created";

"_Filter Modified"
  global $g_myhours;
  $fileinfo=report("{Modified};{Name}|");
  $todaylist="";
  foreach($myitem, $fileinfo, "|") {
    $filedate=gettoken($myitem, 1, ";");
    $filename=gettoken($myitem, 2, ";");
    if ($filedate!="") {if(datediff($filedate, , h) < $g_myhours) {$i++;$todaylist=$todaylist.$filename."|"}}
  }
  if $i > 0 {
    $todaylist=replacelist ($todaylist, "[;]", "", ";");
    selectitems $todaylist;
    $todaylist=regexreplace($todaylist, "\s#.*?\|", "|"); // Remove #... for filter
    filter "By Date" $todaylist;
    #251;
    status("Filtered ".$i." item(s) modified in the last ".$g_myhours." hours");
  } else {
    status("No items modified in the last ".$g_myhours." hours", "883333", stop);
  }

"_Filter Created"
  global $g_myhours;
  $fileinfo=report("{Created};{Name}|");
  $todaylist="";
  foreach($myitem, $fileinfo, "|") {
    $filedate=gettoken($myitem, 1, ";");
    $filename=gettoken($myitem, 2, ";");
    if ($filedate!="") {if(datediff($filedate, , h) < $g_myhours) {$i++;$todaylist=$todaylist.$filename."|"}}
  }
  filter "By Date" $todaylist;
  if $i > 0 {
    status("Filtered ".$i." item(s) created in the last ".$g_myhours." hours");
  } else {
    status("No items created in the last ".$g_myhours." hours", "883333", stop);
  }

"_Filter Size"
  global $g_mysize;
  $fileinfo=report("{Size};{Name}|");
  $todaylist="";
  foreach($myitem, $fileinfo, "|") {
    $filename=gettoken($myitem, 2, ";");
    $filesize=gettoken($myitem, 1, ";");
    $filesize=replace(gettoken($filesize, 1, " MB"), ",", ".");
    if ($filesize > $g_mysize) {$i++;$todaylist=$todaylist.$filename."|"}}
  }
  if $i > 0 {
    $todaylist=replacelist ($todaylist, "[;]", "", ";");
    selectitems $todaylist;
    filter "By Size" $todaylist;
    #251;
    if (get('View')!=0) {#302;}
    sortby "s";
    status("Filtered ".$i." item(s) bigger than ".$g_mysize." MB");
  } else {
    status("No items bigger than ".$g_mysize." MB", "883333", stop);
  }
[/size]||

Re: A couple of scripts I need, please help

Posted: 30 Nov 2012 08:48
by Slavaon
FluxTorpedoe wrote: Though if that may be of interest to some, I could post my full "Filter" button with working generic icons.
If you can do it.
Thank you

Re: A couple of scripts I need, please help

Posted: 01 Dec 2012 09:32
by FluxTorpedoe
Slavaon wrote:
FluxTorpedoe wrote: I could post my full "Filter" button with working generic icons.
If you can do it.
Here it goes: Power Filter [v1.0 alpha1]

Hope you like it, 8)
Flux

Re: A couple of scripts I need, please help

Posted: 01 Dec 2012 10:10
by Slavaon
FluxTorpedoe
Wow. Great job.
Thank you very much.

Re: A couple of scripts I need, please help

Posted: 01 Dec 2012 17:10
by Zephyr
Is there a way to label things automatically so that everything a certain amount of days old is labeled with a blue tag, for example?

Otherwise the script wouldn't be useful to me because the whole point of what I'm trying to get at is an automatic system that keeps all new items identifiable.

Re: A couple of scripts I need, please help

Posted: 02 Dec 2012 04:57
by kunkel321
Can't locked Find Tabs be treated as reusable "filters?"
Since you can Find by date...

EDIT: It looks like Flux might have already scripted this! Will have to check it out! :biggrin:

Re: A couple of scripts I need, please help

Posted: 02 Dec 2012 09:45
by admin
kunkel321 wrote:Can't locked Find Tabs be treated as reusable "filters?"
Since you can Find by date...
Also note the thing called "Search Templates".

Re: A couple of scripts I need, please help

Posted: 03 Dec 2012 10:22
by FluxTorpedoe
Hi'
Not sure what you're after when you talk about filtering based on a "color filter", then about coloring by date...
Zephyr wrote:Is there a way to label things automatically so that everything a certain amount of days old is labeled with a blue tag, for example?
I assumed you were already using the Configuration | Color Filters...
Something like a blue-colored "ageM: <= 72 h" should do the trick (e.g. for files modified in the last 3 days).
AFAIK that's the only "automatic" thing you can have in this regard (I'm not even entering the debate about a permanent looped script).

Hope this helps, 8)
Flux