Page 1 of 1

Folder/File pairs

Posted: 07 Feb 2012 15:16
by Slowfox
I really like the catalog feature.

Most of the time I work with folder pairs.

Is it possible to create a catalog function that will navigate both panes to a folder pair?

Re: Folder/File pairs

Posted: 07 Feb 2012 17:00
by serendipity
Slowfox wrote:I really like the catalog feature.

Most of the time I work with folder pairs.

Is it possible to create a catalog function that will navigate both panes to a folder pair?
Yes you can create such a folder pair.
Right-click on catalog and "Add new item here". At the end of the location field click edit button and paste this code:

Code: Select all

//Folder pairs for dual pane
   focus P1;
   goto "Desktop";
   focus P2;
   goto "My Documents";
This will open Desktop in pane 1 and my documents in pane 2.

Re: Folder/File pairs

Posted: 08 Feb 2012 14:41
by Slowfox
This is great. It does what I want.

It is a bit of a pain, though, to key in all the paths.

Suggestion: Make "Favorite/Catalog Dual Pane" a factory feature.

Thanks.

Re: Folder/File pairs

Posted: 08 Feb 2012 16:57
by serendipity
Slowfox wrote:This is great. It does what I want.

It is a bit of a pain, though, to key in all the paths.

Suggestion: Make "Favorite/Catalog Dual Pane" a factory feature.

Thanks.
If you don't want to key in, you can also browse for folder pair paths for pane 1 and 2 using below script.

Code: Select all

//Create Folder pairs script for catalog
  $path1=inputfolder (<get path 1>, "Path for pane 1");
  $path2=inputfolder (<get path 2>, "Path for pane 2");
  $text= "focus P1; goto ""$path1""; focus P2; goto ""$path2"";";
  copytext $text;
  text $text;

This script will allow you to browse for two folder pairs and make a script. After running this script go to catalog>right-click> "Add new item here" and paste the result from above script in the Location field.

Re: Folder/File pairs

Posted: 08 Feb 2012 22:11
by PeterH
Hi serendipity,

sorry to break into this, but I think there's something "dangerous" in your script:

Code: Select all

  $text= ("focus P1; goto "$path1"; focus P2; goto "$path2";");
  $text=substr($text,1,-1);
I think the first string is "strange"...

Help says (with reason):
It's strongly recommended that you (double- or single-) quote your strings! While the script engine is currently still permissive with unquoted strings (msg Hi! works) this might not be so in the future, so you better do msg "Hi!" right away!
Help / Advanced topics / Scripting / General Command Syntax / Using Quotes in Scripting
(Having written this pointer to the place in help I remember why I don't like the way help is organized. Sorry, Don...)

But your string starts and ends with ( and ), not being in quotes. And then both () are stripped in the next line...
(I assume I know why you did it this way: the double quotes around the pathes.)
I think one possible coding would be:

Code: Select all

  $text= "focus P1; goto ""$path1""; focus P2; goto ""$path2"";";
This is a well quoted string, and quotes inside the string are doubled.

A less elegant version:

Code: Select all

  $text= 'focus P1; goto "' . $path1 . '"; focus P2; goto "' . $path2 . '";';
Here the string is in single quotes - so double quotes are allowed. But as no substitution takes place inside single quotes the variables must be outside the quotes, and concatenated by the dots.
(The blanks around the dots are only for readability and have no meaning.)

Re: Folder/File pairs

Posted: 08 Feb 2012 23:23
by serendipity
@PeterH:
Thanks for pointing that out, I wrote that script in haste, but it works and I tested it before posting, so it was not that dangerous i think (and there is no delete involved).
I did fix it myself on my side later but never posted it as I was at work. Thanks again for that little reminder on how to quote :wink:.
Just fixed the previous script.

Re: Folder/File pairs

Posted: 09 Feb 2012 12:26
by Slowfox
Thanks for the help. It works as intended and is a great improvement.

another question:
Is it possible to modify this script so that the pane paths to be saved are picked off the currently displayed panes. In other words: "I am already displaying the paths that I want to save, why go through the selection again?"

Thanks.

Re: Folder/File pairs

Posted: 09 Feb 2012 16:08
by serendipity
Slowfox wrote:Thanks for the help. It works as intended and is a great improvement.

another question:
Is it possible to modify this script so that the pane paths to be saved are picked off the currently displayed panes. In other words: "I am already displaying the paths that I want to save, why go through the selection again?"

Thanks.
That's just one line then.
Simply run below script and paste in Catalog's location field.

Code: Select all

//Copy paths of both panes to clipboard
  copytext "focus P1; goto ""<get path 1>""; focus P2; goto ""<get path 2>"";";