Collect and paste

Discuss and share scripts and script files...

Collect and paste

Postby serendipity » 09 Sep 2008 20:12

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 20:52, edited 1 time in total.
serendipity
 
Posts: 3314
Joined: 07 May 2007 17:14
Location: NJ/NY

Re: Collect and paste

Postby admin » 09 Sep 2008 20:47

Nice one! :D

PS: you're not totally into quoting strings, are you? :wink: I recommend it to make the scripts "future-safe"...
admin
Site Admin
 
Posts: 31092
Joined: 22 May 2004 15:48
Location: Cologne

Re: Collect and paste

Postby serendipity » 09 Sep 2008 22:17

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: 3314
Joined: 07 May 2007 17:14
Location: NJ/NY

Re: Collect and paste

Postby serendipity » 12 Sep 2008 19:33

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 17:05, edited 4 times in total.
serendipity
 
Posts: 3314
Joined: 07 May 2007 17:14
Location: NJ/NY

Re: Collect and paste

Postby admin » 12 Sep 2008 19:46

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... :)
admin
Site Admin
 
Posts: 31092
Joined: 22 May 2004 15:48
Location: Cologne

Re: Collect and paste

Postby jacky » 12 Sep 2008 20:08

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
jacky
XYwiki Master
 
Posts: 3106
Joined: 23 Aug 2005 21:25
Location: France

Re: Collect and paste

Postby serendipity » 12 Sep 2008 20:25

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.
serendipity
 
Posts: 3314
Joined: 07 May 2007 17:14
Location: NJ/NY

Re: Collect and paste

Postby Plastic » 22 Apr 2009 11:08

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!
Plastic
 
Posts: 36
Joined: 07 Sep 2008 23:18

Re: Collect and paste

Postby lukescammell » 08 Jun 2009 03:21

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 7 x64 Home Premium (at home) | Windows 7 x64 Pro (on laptop) | Windows 7 x64 Ultimate (at work)
lukescammell
 
Posts: 725
Joined: 28 Jul 2006 12:15
Location: Kent, UK

Re: Collect and paste

Postby serendipity » 08 Jun 2009 05:19

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"
serendipity
 
Posts: 3314
Joined: 07 May 2007 17:14
Location: NJ/NY

Re: Collect and paste

Postby aimy » 02 Dec 2009 13:00

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

Image
aimy
 
Posts: 128
Joined: 26 Feb 2007 15:44

Re: Collect and paste

Postby serendipity » 02 Dec 2009 16:27

aimy wrote:Thank you very much serendipity for such an intuitive script...

You are welcome. :D
serendipity
 
Posts: 3314
Joined: 07 May 2007 17:14
Location: NJ/NY

Re: Collect and paste

Postby gogogadgetscottOvr21 » 03 Dec 2009 15:20

Very helpful script. Thank you.
gogogadgetscottOvr21
 
Posts: 7
Joined: 01 Dec 2009 15:31

Re: Collect and paste

Postby lukescammell » 09 Dec 2009 13:30

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 7 x64 Home Premium (at home) | Windows 7 x64 Pro (on laptop) | Windows 7 x64 Ultimate (at work)
lukescammell
 
Posts: 725
Joined: 28 Jul 2006 12:15
Location: Kent, UK

Re: Collect and paste

Postby admin » 09 Dec 2009 13:41

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".
admin
Site Admin
 
Posts: 31092
Joined: 22 May 2004 15:48
Location: Cologne

Next

Return to Script Exchange



Who is online

Users browsing this forum: No registered users and 1 guest