Page 1 of 4

Collect and paste

Posted: 09 Sep 2008 21:12
by serendipity
With this script you can keep collecting items from several folders and when finished simply dump it to where you want.

First: include this script in UDC:

Code: Select all

//Collect
   getkey $c, "items", "collected", "collect.ini";
   focus;
   #101;
   set $p, <clipboard>.<crlf>.$c;
   replace $p, $p, <crlf>,"|";
   replace $p, $p, "||","|";
   setkey $p, "items", "collected", "collect.ini";
and assign a keyboard shortcut to it. Mine is Shift+C.

Next: include this script in UDC:

Code: Select all

//Copyto
   input $c, Copy items to <curpath> (add folder if needed);
   getkey $p, "items", "collected", "collect.ini";
   copyto "<curpath>\$c", $p;
   setkey , "items", "collected", "collect.ini";
again assign a keyboard shortcut to this. Mine is Shift+P.
All set. I simply use Shift+C to collect items I need and finally use Shift+P to dump them.

How it works: Your files will be collected in the collect.ini file inside XYpath and when you are ready, files will be pasted and items in collect.ini will be emptied.

I have tested this 4-5 times now and it works. But be cautious anyways.

Re: Collect and paste

Posted: 09 Sep 2008 21:47
by admin
Nice one! :D

PS: you're not totally into quoting strings, are you? :wink: I recommend it to make the scripts "future-safe"...

Re: Collect and paste

Posted: 09 Sep 2008 23:17
by serendipity
Forgot to mention, obviously one can have moveto and backupto too!

Code: Select all

//Moveto
   input $c, Move items to <curpath> (add folder if needed);
   getkey $p, "items", "collected", "collect.ini";
   moveto "<curpath>\$c", $p;
   setkey , "items", "collected", "collect.ini";

Code: Select all

//Backupto
   input $c, Backup items to <curpath> (add folder if needed);
   getkey $p, "items", "collected", "collect.ini";
   backupto "<curpath>\$c", $p;
   setkey , "items", "collected", "collect.ini";

Re: Collect and paste

Posted: 12 Sep 2008 20:33
by serendipity
A full suite for collecting items, its somewhat friendly now. Include this script in scripts folder and name the file collect.xys.

Code: Select all

//Collect
"Collect items : collect"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   focus;
   
   $SelectedItemsPath= getinfo ("SelectedItemsPathNames", "|");
   $CountSelectedItems= getinfo ("CountSelected");
     
   set $Items, $SelectedItemsPath.$Items;
   incr $Count, $Count, $CountSelectedItems;
      
   setkey $Items, "items", "collected", "collect.ini"; 
   setkey $Count, "count", "collected", "collect.ini"; 
   status "Items collected=$CountSelectedItems (Total=$Count)", BF0000, progress;   
   focus c;
- 
"Copy items to : copyto"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   text $ForTextMessage, , , "You have collected $Count items, you can choose where to copy them next.",w;
   inputfolder $Path, <curpath>, Choose folder to copy items to;
   copyto "$Path", $Items;
   setkey , "items", "collected", "collect.ini";
   setkey , "count", "collected", "collect.ini";
   status "$Count Items Copied", , Ready;
   focus c;

  
"Move items to : moveto"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   text $ForTextMessage, , , "You have collected $Count items, you can choose where to Move them next.",w;
   inputfolder $Path, <curpath>, Choose folder to Move items to;
   moveto "$Path", $Items;
   setkey , "items", "collected", "collect.ini";
   setkey , "count", "collected", "collect.ini";
   status "$Count Items Moved", , Ready;
   focus c;
   
"Backup items to : backupto"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   text $ForTextMessage, , , "You have collected $Count items, you can choose where to Back them up next.",w;
   inputfolder $Path, <curpath>, Choose folder to Backup items to;
   backupto "$Path", $Items;
   setkey , "items", "collected", "collect.ini";
   setkey , "count", "collected", "collect.ini";
   status "$Count Items Backedup", , Ready;
   focus c;
-
"Show collected items : show"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   incr $Count, $Count,0;
   text $ForTextMessage, , , "You have collected $Count items",w;


"Empty collected items : empty"
   setkey 1, "exists", "tmp", "collect.ini";
   self $path, path;
   delete 0, 0, "$path\collect.ini";
   status "Collected items emptied", , alert;
   focus c;
- 

"Edit script : edit"
   self $ScriptFile, file;
   Open $ScriptFile,w;
-
"Cancel"
And add this new item to the catalog:

Code: Select all

::load collect
All set. :D

Updated: 18th April '09

Re: Collect and paste

Posted: 12 Sep 2008 20:46
by admin

Code: Select all

"Edit script : edit"
   self $p, file;
   Open $p,w;
I like this part. :) Like the script is open for adjustments... evolution, "mutations this way, please!"

I tried the script as internal script in a catalog item. This part does not work then since there is no file to open. And currently scripting cannot change catalog items. Which might change with snippets... :)

Re: Collect and paste

Posted: 12 Sep 2008 21:08
by jacky
Yep, very nice script! :)

Couple of things if I may :

- You should quote your strings, always, I say
- I'd recommend using more meaningful var names, but that's me ;) You got some error though:

Code: Select all

   inputfolder $c, <curpath>, Choose folder to M/C/B items to;
   backupto "$f", $a;
$f doesn't exist, should be $c I guess, no?

PS: for your script "empty", personally I'd remove the INI:

Code: Select all

  setkey 1, "exists", "tmp", "collect.ini";
  self $path, path;
  delete 0, 0, "$path\collect.ini";
I just like it better that way! ;)

Re: Collect and paste

Posted: 12 Sep 2008 21:25
by serendipity
jacky wrote:Yep, very nice script! :)

Couple of things if I may :

- You should quote your strings, always, I say
- I'd recommend using more meaningful var names, but that's me ;) You got some error though:

Code: Select all

   inputfolder $c, <curpath>, Choose folder to M/C/B items to;
   backupto "$f", $a;
$f doesn't exist, should be $c I guess, no?

PS: for your script "empty", personally I'd remove the INI:

Code: Select all

  setkey 1, "exists", "tmp", "collect.ini";
  self $path, path;
  delete 0, 0, "$path\collect.ini";
I just like it better that way! ;)
Thanks Jacky, very useful comments. I already changed the error, and will change variables to something meaningful.
And I did not delete the collect.ini because i wanted the message "you have collected 0 items" when I do show message. But I guess I can use incr command too to do it.
Thanks again.

Re: Collect and paste

Posted: 22 Apr 2009 12:08
by Plastic
Hi!

I found this script very useful, and I made a little modification to allow modification of the collected files directly in the "Show collected items" dialog:

Code: Select all

"Show collected items : show"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   incr $Count, $Count,0;
   text $ForTextMessage, , , "You have collected $Count items",w;
   
   // Cancel = same message => no modification
   $Response = input("You have collected $Count items", , $ForTextMessage, w, $ForTextMessage);
   
   // Update $Items
   replace $Items, $Response, "<crlf>", "|";
   
   // Update $Count
   regexreplace $Tokens, $Items, "[^|]";
   strlen $Count, $Tokens;
   
   setkey $Items, "items", "collected", "collect.ini";
   setkey $Count, "count", "collected", "collect.ini";
For simplicity, Cancel update the variables as well, but it can surely be optimized.

Regards!

Re: Collect and paste

Posted: 08 Jun 2009 04:21
by lukescammell
I get an error on line 12 with XY 7.90.0410 - I'm beginning to think it's my config that's broken...

Re: Collect and paste

Posted: 08 Jun 2009 06:19
by serendipity
I did some changes recently but forgot to update here, try the below script and see if you still get the error:

Code: Select all

//Collect
"Collect items : collect"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   focus;
   
   $SelectedItemsPath= getinfo ("SelectedItemsPathNames", "|");
   $CountSelectedItems= getinfo ("CountSelected");
     
   set $Items, $SelectedItemsPath.$Items;
   incr $Count, $Count, $CountSelectedItems;
      
   setkey $Items, "items", "collected", "collect.ini"; 
   setkey $Count, "count", "collected", "collect.ini"; 
   status "Items collected=$CountSelectedItems (Total=$Count)", BF0000, progress;   
   focus c;
- 
"Copy items to : copyto"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   text $ForTextMessage, , , "You have collected $Count items, you can choose where to copy them next.",w;
   inputfolder $Path, <curpath>, Choose folder to copy items to;
   copyto "$Path", $Items;
   setkey , "items", "collected", "collect.ini";
   setkey , "count", "collected", "collect.ini";
   status "$Count Items Copied", , Ready;
   focus c;

  
"Move items to : moveto"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   text $ForTextMessage, , , "You have collected $Count items, you can choose where to Move them next.",w;
   inputfolder $Path, <curpath>, Choose folder to Move items to;
   moveto "$Path", $Items;
   setkey , "items", "collected", "collect.ini";
   setkey , "count", "collected", "collect.ini";
   status "$Count Items Moved", , Ready;
   focus c;
   
"Backup items to : backupto"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   text $ForTextMessage, , , "You have collected $Count items, you can choose where to Back them up next.",w;
   inputfolder $Path, <curpath>, Choose folder to Backup items to;
   backupto "$Path", $Items;
   setkey , "items", "collected", "collect.ini";
   setkey , "count", "collected", "collect.ini";
   status "$Count Items Backedup", , Ready;
   focus c;
-
"Show collected items : show"
   getkey $Items, "items", "collected", "collect.ini";
   getkey $Count, "count", "collected", "collect.ini";
   replace $ForTextMessage, $Items, "|",<crlf>;
   incr $Count, $Count,0;
   
   //text $ForTextMessage, , , "You have collected $Count items",w;
   
   // Cancel = same message => no modification
   $Response = input("You have collected $Count items (you can add/remove items)", , $ForTextMessage, w, $ForTextMessage);
   
   // Update $Items
      replace $Items, $Response, "<crlf>", "|";
         
   // Update $Count
   regexreplace $Tokens, $Items, "[^|]";
   strlen $Count, $Tokens;
   
   setkey $Items, "items", "collected", "collect.ini";
   setkey $Count, "count", "collected", "collect.ini";


"Empty collected items : empty"
   setkey 1, "exists", "tmp", "collect.ini";
   self $path, path;
   delete 0, 0, "$path\collect.ini";
   status "Collected items emptied", , alert;
   focus c;
- 

"Edit script : edit"
   self $ScriptFile, file;
   Open $ScriptFile,w;
-
"Cancel"

Re: Collect and paste

Posted: 02 Dec 2009 13:00
by aimy
Thank you very much serendipity for such an intuitive script...

Image

Re: Collect and paste

Posted: 02 Dec 2009 16:27
by serendipity
aimy wrote:Thank you very much serendipity for such an intuitive script...
You are welcome. :D

Re: Collect and paste

Posted: 03 Dec 2009 15:20
by gogogadgetscottOvr21
Very helpful script. Thank you.

Re: Collect and paste

Posted: 09 Dec 2009 13:30
by lukescammell
Finally got this working - that stupid "SELECT ALL" in the code block puts an extra tab at the beginning of every line for me and that was fouling it up :/

Really very useful, thanks!

One small point, I have the script in the Catalogue for easy access to all the options and 4 UDCs (see below) for activating collect, copyto, moveto and show. When I use the UDC to collect a file in the list view, the list view loses fcus and the script in the catalogue gets focus. Is there any way to stop this happening? I'd much rather the focus remained where I was to start with. Perhaps a message to the status bar could be made, such as "5 new items collected"?

My Catalogue:

Code: Select all

Caption:                     Collect
Location:                    ::load collect

Advanced
Action on click:             Go to location
For applications, open multiple files with: Single instance
My UDCs:

Code: Select all

Category:                    Load Script File
Caption:                     Collect: collect
Script File:                 collect
Label:                       collect
Assign Keyboard Shortcut...: Shift+C
On KeyUp:                    yes

Category:                    Load Script File
Caption:                     Collect: paste
Script File:                 collect
Label:                       copyto
Assign Keyboard Shortcut...: Shift+V
On KeyUp:                    yes

Category:                    Load Script File
Caption:                     Collect: move
Script File:                 collect
Label:                       moveto
Assign Keyboard Shortcut...: Shift+X
On KeyUp:                    yes

Category:                    Load Script File
Caption:                     Collect: show
Script File:                 collect
Label:                       show
Assign Keyboard Shortcut...: Shift+S
On KeyUp:                    yes
I wish there was an "Import" and "Export" button on the UDCs dialogue that enabled you to share a text/ini/xml file with other XY users...

Re: Collect and paste

Posted: 09 Dec 2009 13:41
by admin
lukescammell wrote:I wish there was an "Import" and "Export" button on the UDCs dialogue that enabled you to share a text/ini/xml file with other XY users...
Is planned as "snippets".