Collect and paste

Discuss and share scripts and script files...
serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Collect and paste

Post 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.
Last edited by serendipity on 09 Sep 2008 21:52, edited 1 time in total.

admin
Site Admin
Posts: 60291
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Collect and paste

Post 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"...

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Collect and paste

Post 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";

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Collect and paste

Post 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
Last edited by serendipity on 18 Apr 2009 18:05, edited 4 times in total.

admin
Site Admin
Posts: 60291
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Collect and paste

Post 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... :)

jacky
XYwiki Master
Posts: 3106
Joined: 23 Aug 2005 22:25
Location: France
Contact:

Re: Collect and paste

Post 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! ;)
Proud XYplorer Fanatic

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Collect and paste

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

Plastic
Posts: 36
Joined: 08 Sep 2008 00:18

Re: Collect and paste

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

lukescammell
Posts: 744
Joined: 28 Jul 2006 13:15
Location: Kent, UK
Contact:

Re: Collect and paste

Post 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...
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Collect and paste

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

aimy
Posts: 181
Joined: 26 Feb 2007 15:44

Re: Collect and paste

Post by aimy »

Thank you very much serendipity for such an intuitive script...

Image

serendipity
Posts: 3358
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: Collect and paste

Post by serendipity »

aimy wrote:Thank you very much serendipity for such an intuitive script...
You are welcome. :D

gogogadgetscottOvr21
Posts: 8
Joined: 01 Dec 2009 15:31

Re: Collect and paste

Post by gogogadgetscottOvr21 »

Very helpful script. Thank you.

lukescammell
Posts: 744
Joined: 28 Jul 2006 13:15
Location: Kent, UK
Contact:

Re: Collect and paste

Post 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...
Used to update to the latest beta every day. Now I have children instead…
Windows 10 Pro x64 (everywhere except phone…)

admin
Site Admin
Posts: 60291
Joined: 22 May 2004 16:48
Location: Win8.1 @100%, Win10 @100%
Contact:

Re: Collect and paste

Post 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".

Post Reply