Page 1 of 1

Propagate Files Across Selected Folders.

Posted: 15 Oct 2010 02:34
by SkyFrontier
I needed to spread a file for a set of folders.
Came up with this:

Code: Select all

   Focus("PI");
   #807;
   Focus("PI");
But this left me wondering: wouldn't be cool if we could have a way to do that say,

select target folders;
go to the opposite pane and select file(s)/folder(s) to propagate;
use the function to propagate (copy/move/backup) selection on target folders at the (now) opposite/inactive pane?

EDIT: At the end I did almost the old style: opening each target folder by hand and activating CKS'ed script. Of course there was some gain, but could be a bit better/automated.

Re: Propagate Files Across Selected Folders.

Posted: 15 Oct 2010 04:00
by SkyFrontier
...aaaah, NINJA STYLE!

Code: Select all

   $a = getinfo("item", i); backupto "<curpath>", "$a"
(at least regarding one target folder at a time... :| )

Re: Propagate Files Across Selected Folders.

Posted: 15 Oct 2010 06:51
by SkyFrontier
Came with this but refuses to work; one attempt worked fine with a single target location. Any help, please...?

Code: Select all

   $t1 = Report("{FullName}", 1);
   $t2 = getinfo("item", i);
   backupto "$t1", "$t2";
EDIT: and this one worked for 1 file and 1 folder. :|

Code: Select all

   $t1 = getinfo("SelectedItemsPathNames", "|");
   $t2 = getinfo("item", i);
   backupto "$t1", "$t2";

Re: Propagate Files Across Selected Folders.

Posted: 15 Oct 2010 09:58
by SkyFrontier
It's stupid and has no error checking (every pre-requisite must be set by user), but almost does the job (works fine for single folder as destination - which is far from what I intend, that is: backing/copying up stuff to selected folders on inactive pane!):

Code: Select all

   $t1 = getinfo("SelectedItemsPathNames", "|");
   focus "pi";
   $t2 = getinfo("SelectedItemsPathNames", "|");
   backupto "$t1", "$t2";
   focus "pi";
-how do I force it to specify/return path names as required by backupto? (something like "c:\test 1", "c:\temp")
Thanks!

Re: Propagate Files Across Selected Folders.

Posted: 15 Oct 2010 11:02
by Stefan
SF>(something like "c:\test 1", "c:\temp")

You will get this with this code:
$t1 = '"' . getinfo("SelectedItemsPathNames", """, """) . '"';

where
""", """ are two times " + " + "

and
'"' is ' + " +'
(or four "s like """" >>> $t1 = """" . getinfo("SelectedItemsPathNames", """, """) . """";)


But Do backupto allow several targets at once?


-


I think i would code it like this:

Code: Select all

//select in left pane one file to copy.
//switch to right pane and select target folders.
//execute this script:

//get target folders names:
$targets = getinfo("SelectedItemsPathNames", "|");

   //go back to left and get selected item:
   focus "pi";
   $source = "<curitem>"; //getinfo("SelectedItemsPathNames", "|");

   //for each target in targetS do:
   $Loop=1;
   while(1){
      $target = gettoken($targets, $Loop, "|");
      if ($target==""){break;}

      //copy source to current selected target:
      //copyto location, source
      copyto $target, $source;

   incr $Loop;
   }

   focus "pi";
   goto gettoken($targets, 1, "|");

Re: Propagate Files Across Selected Folders.

Posted: 15 Oct 2010 16:27
by SkyFrontier
Phew... for a moment I thought it should be some kind of limitation, being that the number of maximum items selected as source or target forcibly having to be "1".
Then I tested the $source comment - it was an option/suggestion, not a denial.
The custom version (backup instead of copy - yes, it works!, work with several items as source, minor end-of-process cosmetic changes) goes like this:

Code: Select all

//select in left pane one file to copy.
//switch to right pane and select target folders.
//execute this script:

//get target folders names:
   $targets = getinfo("SelectedItemsPathNames", "|");

   //go back to left and get selected item:
   focus "pi";
   $source = getinfo("SelectedItemsPathNames", "|"); //"<curitem>";

   //for each target in targetS do:
   $Loop=1;
   while(1){
      $target = gettoken($targets, $Loop, "|");
      if ($target==""){break;}

      //copy source to current selected target:
      //copyto location, source
      backupto $target, $source;

   incr $Loop;
   }

   focus "pi";
//   goto gettoken($targets, 1, "|");
   status "Selection/bkp propagated. Thanks!"
I'm yet to understand if/then/elseif and loop/incremental commands to work on several items at a time. Hope this one enlights me...

-am I missing something or I "really" can't directly set several destination paths as source for backup/copy operations, except by repeating the commands, one command per destination?

Code: Select all

//wrong???
   copyto "<xydata>\BKPs\|d:\backups\|c:\burn\today", "<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates";
instead of

Code: Select all

//right!
   copyto "<xydata>\BKPs\", "<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates";
   copyto "d:\backups\", "<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates";
   copyto "c:\burn\today", "<xydata>\*.ini|<xydata>\*.dat|<xydata>\FindTemplates";
Thanks!