script query - rename in previous pane [Highend]

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

script query - rename in previous pane [Highend]

Post by calude »

I had this Autohotkey script, that I made years ago, that worked fine and today no way to make it work again......
instead of having AHK sending keystrokes to XYplorer I guess doing the same job in XY would be more effective and reliable
but I'm a musician not a programmer so I need someone to write for me this simple script.
Highend has helped me previously and will again be rewarded because he is so generous of his time here.

in Right pane I have a bunch of fresh scanned PDF's (manuscript songs transcriptions) sequentially named by my scanner, preview pane open at right.
in Left pane I have a big collection of audio files named by their Artist-songtitle.

the renaming process as I did with AHK:
in Right pane select a pdf (click)
remember artist and song
in Left pane search the corresponding artist and song
select it (click)
LAUNCH script by a keyboard shortcut
script:
copy the Artist-songtitle as is
remame the previously selected PDF
select next item

maybe the script could include the search in left pane

Thanks for your kind help

Calude

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

Why shouldn't the whole process be automated?
Look for all pdfs in either pane and get the corresponding mp3 names from the other pane
=> Rename all pdfs accordingly?

What are the exact file names that the scanner produces?
One of my scripts helped you out? Please donate via Paypal

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script query - rename in previous pane [Highend]

Post by calude »

highend wrote:Why shouldn't the whole process be automated?
Look for all pdfs in either pane and get the corresponding mp3 names from the other pane
=> Rename all pdfs accordingly?

What are the exact file names that the scanner produces?
impossible
the pdfs are scans of hand written music charts named sequentially by the scanner
they need my eye no OCR will do

Calude

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

? How should a script find the right mp3 for a sequentially named pdf file?
One of my scripts helped you out? Please donate via Paypal

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script query - rename in previous pane [Highend]

Post by calude »

highend wrote:? How should a script find the right mp3 for a sequentially named pdf file?
I indentify the name of the pdf by looking at it
then go to the other pane search for the mp3 that has the corresponding name
select it
then I launch the script that does the renaming according to the selected mp3
and goes back to the pdf pane and select/display the next pdf
end of script
Identify the next pdf etc etc


the goal is to always have a mp3 and the music chart with exactly the same name

Calude

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

Code: Select all

    $itemInactivePane  = get("Item", "i");
    end !get("#800"), "Dual pane not active, aborted!";

    $itemsInactivePane = listpane("i", , , <crlf>);
    if (!$itemsInactivePane) { status "No item(s) in inactive pane, aborted!", , "alert"; end true; }
    $indexInactivePane = gettokenindex($itemInactivePane, $itemsInactivePane, <crlf>, "");
    $nextInactivePane  = gettoken($itemsInactivePane, $indexInactivePane + 1, <crlf>);

    renameitem(gpc(<curitem>, "base"), $itemInactivePane);
    focus "PI";
    selectitems $nextInactivePane;
One of my scripts helped you out? Please donate via Paypal

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script query - rename in previous pane [Highend]

Post by calude »

Highen thankyou
it works exactly as I wanted

:tup: :tup: :tup: :tup:

have a nice evening

Calude

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

No problem.
Btw, I edited the script above to include two security checks (dual pane mode active, the inactive pane contains files)...
One of my scripts helped you out? Please donate via Paypal

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script query - rename in previous pane [Highend]

Post by calude »

Thanks for the security add-on

I still have a small glitch :

when the script comes back to the pdf pane and selects the next file it forgets to refresh the preview !!

Cal

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

Mh, on my system the next scripted selecting of a pdf file automatically refreshes the preview pane and shows the correct content?
One of my scripts helped you out? Please donate via Paypal

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script query - rename in previous pane [Highend]

Post by calude »

I suppose it worked fine the first times I tried your script or I wouldnt have written that it was working as I wanted ...

But it doesnt anymore
for the record the first fails to refresh where already on the original version of the script

Cal

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

The script itself doesn't do any refreshing and if it worked in the first place the problem is somewhere else

Go into the folder with your pdfs. Open the preview pane
Select the first .pdf file
Now execute this from the address bar:

Code: Select all

sel "+1";
The next file is now selected.
Does the preview pane show the correct content now?
One of my scripts helped you out? Please donate via Paypal

calude
Posts: 355
Joined: 13 Aug 2008 10:16
Location: Switzerland
Contact:

Re: script query - rename in previous pane [Highend]

Post by calude »

highend wrote: Does the preview pane show the correct content now?
yes it does with the code you suplied

Code: Select all

sel "+1";
but still no joy
when I fire the script
I can see a fast flash in the preview pane but it ends empty

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

Ic. It seems selectitems
has a problem that sel doesn't have.

I'll rewrite the file selection part...
One of my scripts helped you out? Please donate via Paypal

highend
Posts: 15003
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: script query - rename in previous pane [Highend]

Post by highend »

Try this version

Code: Select all

    end !get("#800"), "Dual pane not active, aborted!";

    // Get current items in inactive pane
    $curItemInactivePane  = get("Item", "i");
    $curItemsInactivePane = listpane("i", , , <crlf>);
    if (!$curItemsInactivePane) { status "No item(s) in inactive pane, aborted!", , "alert"; end true; }
    $curIndexInactivePane = gettokenindex($curItemInactivePane, $curItemsInactivePane, <crlf>, "");
    $nextFileInactivePane = gettoken($curItemsInactivePane, $curIndexInactivePane + 1, <crlf>);

    // Rename item
    $renamed = renameitem(gpc(<curitem>, "base"), $curItemInactivePane);

    // Get nex indexes in active pane
    $newItemsInactivePane = listfolder(get("Path", "i"), , , <crlf>);
    $newItemIndexInactivePane = get("FocusedPos", "i");
    $renamedItemIndexInactivePane = gettokenindex($renamed, $newItemsInactivePane, <crlf>, "");

    // Switch pane and select file
    focus "PI";
    if ($renamedItemIndexInactivePane <= $newItemIndexInactivePane) { sel "+1"; }
    else { sel "+0"; }
One of my scripts helped you out? Please donate via Paypal

Post Reply