Page 1 of 2
Need script for collect item/s path/s (#101), to text file
Posted: 16 Sep 2012 13:43
by Dario
Every new added path/s, should be below existing paths.
Thanks everyone for the help
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 15:20
by Stefan
Please describe step-by-step what you want to do...
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 16:50
by Dario
I have one text file (ItemsPaths.text), and from time to time, I need to add some selected files/folders paths to this text file. I do it manually. Select files/folders, press Ctrl+P, open text file, and paste new paths, below existed paths. One line, one path. I'd like to do automatic, with script, if it possible.
thanks
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 16:59
by Marco
First of all select the desired files, then run
Code: Select all
#101;
writefile("PATHTOYOURTEXTFILE",<crlf>.<clipboard>,"a","t");
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 18:03
by Dario
Thank you very much Marco.
Script work as I want, and one more thing if it possible. When I use script, I've got somtimes empty line between paths, not allways. I don't know why. Is it possible do it without empty line.
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 18:34
by Marco
Dario wrote:Thank you very much Marco.
Script work as I want, and one more thing if it possible. When I use script, I've got somtimes empty line between paths, not allways. I don't know why. Is it possible do it without empty line.
Sure, I just discovered that #101 returns a final line feed. This should not add empty lines, let me know it if fits your needs
Code: Select all
#101;
writefile("PATHTOYOURTEXTFILE",<clipboard>,"a","t");
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 19:45
by Dario
Yes, last script works exactly what I want.

I appreciate your help very much. I hope you live to be a hundred years, like a rich man.
thanks
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 21:06
by admin
Dario wrote:Yes, last script works exactly what I want.

I appreciate your help very much. I hope you live to be a hundred years, like a rich man.
thanks
Me too, me too! What every artist wants (acc. to Freud):
money, fame, and beautiful lovers.
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 16 Sep 2012 22:46
by Marco
Thank you Dario, far too kind!
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 17 Sep 2012 09:16
by Stefan
#101 is "File | To Clipboard | Item Path/Name(s) (Ctrl+P)"
We can do this without using the clipboard too:
Code: Select all
::writefile("%temp%\xyCollectedFiles.txt", "<get SelectedItemsPathNames><crlf>","a");
"%temp%\xyCollectedFiles.txt" is just an temporary file in the users temp folder.
"<get SelectedItemsPathNames><crlf>" returns the currently selected file names incl. path, plus an last line break.
,"a" is an writefile() parameter, find more about in the help > Adv. Topics > Scripting Commands Reference, to see e.g. how to store unicode names.
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 17 Sep 2012 18:09
by klownboy
Thanks Marco and Stefan, the small script makes it easy to add selected files to a file list. Irfanview has a great wallpaper feature that allows you to change wallpaper on-the-fly using command line parameters similar to this example:
Code: Select all
D:\Graphics\IrfanView\i_view32.exe /filelist=G:\Pictures\Ireland Trip 2011\Ireland_16x9.txt /random /wall=3 /killmesoftly
So using your little script and assigning it a catalog item or toolbar button allows me to quickly add files to the list. I've assigned the above irfanview command as a pinned item on the taskbar so one click on its icon and the wallpaper changes and without background resources overhead. Very slick!
Thanks,
Ken
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 17 Sep 2012 21:47
by Stefan
Just for the fun
i take this issue to do something with HTML() script command
to provide an User Input Dialog with own Buttons:
Code: Select all
//Store the collection to this file:
$file= "%tmp%\xyTempCollector.txt";
//Prompt the user with an dialog:
// See Help > Adv. Topics > Scripting Command Reference > HTML
$html = urldecode(html('<html><body><form method="get" action="xys:">
<H3>Save the names of the selected files to an text file</H3>
List of selected files:<BR>
<TEXTAREA WRAP=Off NAME="taINPUT" ROWS=14 COLS=90>'. "<get SelectedItemsPathNames>" .'</TEXTAREA>
<BR>
<BR>
Collect to file<BR>
<font color="blue">'.$file.'</font><BR>
<BR>
<INPUT type="submit" name="actOpenColl" value="Open >" >
<INPUT type="submit" name="actCollNow" value="Collect Now To File!" >
<INPUT type="submit" name="actCollOpen" value="Collect Now AND Open File >" >
</form></body></html>',"830", "600", "Collect Files"));
//get the dialog results if an button was clicked:
end($html=="");
// msg 'Debug: ' .$html;
/*
Debug example:
Debug: ?taINPUT=E:\temp\XY_Script_tests\Test File Name-08.txt
E:\temp\XY_Script_tests\Test File Name-09.txt
E:\temp\XY_Script_tests\Test File Name-10.txt&OpenColl=Open >
*/
// proceed the returned data:
//Get the first part from an '&' subdivided string (File Name-10.txt&OpenColl),
// then the second part of an '=' subdivided string (?taINPUT=E:\temp\):
$SelFiles = gettoken( gettoken($html, "1", "&") ,2, "=" ) . "<crlf>";
//Get the second part from '&' and from that the first of '=' (&OpenColl=)
$Action = gettoken( gettoken($html, "2", "&") ,1, "=" );
//debug:
// msg "SelFiles: " . $SelFiles;
// msg "Action?: " . $Action;
// Do something with the returned data:
if ($Action == "actCollOpen"){
writefile( $file, $SelFiles, "a" );
run notepad $file;
end(1);
}
if ($Action == "actCollNow"){
writefile( $file, $SelFiles, "a" );
//run notepad $file;
end(1);
}
if ($Action == "actOpenColl") {
if(exists($file)==1){
run notepad $file;
}else{
msg "File doesn't exist yet. Collect something first.";
}
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 18 Sep 2012 02:48
by klownboy
Hi Stefan, Amazing! Your script worked great. I changed "$file" to the text file inwhich I've been saving my jpg file names (with path). Then, I selected some of my newly formatted jpgs with a changed aspect ratio to suit as my desktop wallpaper. The script showed the files in the table and the files were properly added to my existing list - Bingo, it all went off without a hitch!
One note though, when I selected "Open" the text file only, the file opened properly, but I half expected I'd be able to continue afterwards and then add the selected files, but instead it closes. Not a biggie now that I know, but it might be nice to be able to open the file and then perform the addition of the selected files (realizing of course that the open file would have to be reopend to accomplish the save, but I think notepad will tell you that automatically and reopen the file to save the changes. Could the script cycle back or ccontinue and not close out?
Another note (again not that important): I also attempted to change the text editor from "notepad" to "textpad" by changing the appropriated lines to:
Code: Select all
run D:\Tools\TextPad\TextPad.exe $file;
However, I received an "overflow 0/0" error when I ran the script after selecting "Open". I obviously don't need to use textpad in this case, but I was wondering what I might need to change to prevent the message.
Thanks again for a very helpful script,
Ken
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 18 Sep 2012 08:06
by Stefan
klownboy wrote:Hi Stefan, Amazing! Your script worked great.
Hi Ken, thanks for feedback! Hoping many new users see what else is possible with scripting.
One note though, when I selected "Open" the text file only, the file opened properly,
but I half expected I'd be able to continue afterwards and then add the selected files, but instead it closes.
I think that's by design. The opened notepad just shows you the list and you can edit it if needed.
To have the file open and still add new lines from selected files is not possible this way.
I would have to use an other technic... or maybe it would be possible by reloading the script
always after adding new lines, but that's is not planed by me...
I also attempted to change the text editor from "notepad" to "textpad"
by changing the appropriated lines to:
Code: Select all
run D:\Tools\TextPad\TextPad.exe $file;
However, I received an "overflow 0/0" error when I ran the script after selecting "Open".
Such overflow is mostly (ever?) evoked by un-proper quoting.
My 'notepad' is an well know term (i don't know the proper description right now) stored in the registry,
but to call an executable with an path you have to use quotes:
Code: Select all
run "D:\Tools\TextPad\TextPad.exe" $file;
Somewhere in an post down the thread from my signature is an overview about quoting, if you are interested.
Re: Need script for collect item/s path/s (#101), to text fi
Posted: 18 Sep 2012 14:31
by klownboy
Hi Stefan, Many thanks for the script. Hopefully other users stumble across this handy script. I'm sure there are many cases where someone wants to collect file names with paths to a file. It will be very handy in my case using it to add jpg file names for use as a Irfanview wallpaper.
I've been tinkering with AutoHotkey somewhat in the past couple of months. Very nice scripting possibilities inside and outside of XYplorer...just a beginner though.
It was forgetful of me not to have quoted the textpad name/path. I did after your last post and it ran fine using testpad in lieu of notepad. For experimentation purposes, I opened the text file externally using textpad and then ran the script and used the option to add the selected files and open textpad. The editor simply asked the question, "Another application has updated the text file (i.e., the file name). Do you want to reload it?" Obviously, these are the changes made due to the script. I replied OK, and the update was made. - no issues.
Thanks again,
Ken