Page 1 of 2
script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 16:22
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
Re: script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 16:30
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?
Re: script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 16:40
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
Re: script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 16:57
by highend
? How should a script find the right mp3 for a sequentially named pdf file?
Re: script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 17:05
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
Re: script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 17:58
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;
Re: script query - rename in previous pane [Highend]
Posted: 04 Jul 2017 18:20
by calude
Highen thankyou
it works exactly as I wanted
have a nice evening
Calude
Re: script query - rename in previous pane [Highend]
Posted: 05 Jul 2017 04:00
by highend
No problem.
Btw, I edited the script above to include two security checks (dual pane mode active, the inactive pane contains files)...
Re: script query - rename in previous pane [Highend]
Posted: 07 Jul 2017 12:28
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
Re: script query - rename in previous pane [Highend]
Posted: 07 Jul 2017 12:34
by highend
Mh, on my system the next scripted selecting of a pdf file automatically refreshes the preview pane and shows the correct content?
Re: script query - rename in previous pane [Highend]
Posted: 08 Jul 2017 12:27
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
Re: script query - rename in previous pane [Highend]
Posted: 10 Jul 2017 09:11
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:
The next file is now selected.
Does the preview pane show the correct content now?
Re: script query - rename in previous pane [Highend]
Posted: 11 Jul 2017 13:33
by calude
highend wrote:
Does the preview pane show the correct content now?
yes it does with the code you suplied
but still no joy
when I fire the script
I can see a fast flash in the preview pane but it ends empty
Re: script query - rename in previous pane [Highend]
Posted: 11 Jul 2017 13:44
by highend
Ic. It seems selectitems
has a problem that sel doesn't have.
I'll rewrite the file selection part...
Re: script query - rename in previous pane [Highend]
Posted: 11 Jul 2017 14:55
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"; }