Changing File association (is this the right forum topic?)

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
KeepItSimplePaul
Posts: 2
Joined: 10 Jan 2012 12:01

Changing File association (is this the right forum topic?)

Post by KeepItSimplePaul »

Hello,
I registered a little while ago and am posting because I hav e trouble understanding the manual. Also, Xyplorer is better than windows Explorer!

What steps(scripts???) can I take for two situations --for example, if I have 5 different programs working with a .TXT file and in one week,
1. I want just two particular programs to be top of Xyplorer's association list (the "Open with"
icon),
2. With the same TXT files, I also want to change window Explorer's program file association list, to allow the SAME TWO PROGRAMS to be on popping up on the list, following the right -mouse click inside Xyplorer (and one click later, to open the Windows Explorer's "open
with")

1.What steps/scripts do I need for part 1?
.
2.And, can I work through Xyplorer for part 2, or is there any recommended software/add-
on/plug-in approach I can reliably use?

(Are these two parts entirely different questions?).

Finally, onto a better search approach to forum postings:
I tried to do a MANUAL search for "association" on the forum topics --ouch, my eyes are hurting, if there a better software approach that SAVES the specific pages for offline reading, INCLUDING closely misspelled wordings, please please tell me!!! :oops:

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

Re: Changing File association (is this the right forum topic

Post by highend »

Everything is possible, it's just a question of how much effort somebody is willing to put into it.

1. The pro version of XY allows scripting and can be used to accomplish what you want.
The XYplorer.ini file contains the portable file associations (under [FileAssoc]). These could be read, resorted and saved back to the config file (through scripting commands). After that XYplorer must be restarted with the modified configuration.

I don't think that such a script already exists (and I don't find the approach interesting enough to code it myself...).

2. Possible as well. You have to clear the MRUList for each filetype that you want to modify (or reorder it).
E.g.:

Code: Select all

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.avi\OpenWithList]
And then add the necessary entries (back) in the right order.
One of my scripts helped you out? Please donate via Paypal

KeepItSimplePaul
Posts: 2
Joined: 10 Jan 2012 12:01

Re: Changing File association (is this the right forum topic

Post by KeepItSimplePaul »

Thank you very much, Highend :D
I will look up the areas you highlighted.

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

Re: Changing File association (is this the right forum topic

Post by highend »

The first point was easy enough:

1. Make a backup of your XYplorer.ini file!

2. Create a new folder in your user directory (in my example (portable installation) I made a folder named "Associations" inside the "Data" folder of XYplorers root dir.

3. Open your XYplorer.ini with an editor. Search for [FileAssoc]. Copy the whole block to a new editor window, modify it to suit your needs, make sure you add two trailing empty lines to the end of the file and save it in the newly created folder (e.g.: Txt_NPPlus_Editplus.ini).

E.g.:

Code: Select all

[FileAssoc]
Count=4
1=+"VLC Media Player" avi;flv;iso;img;m2ts;mkv;mov;mp4;mpg;mpeg;ts;vob;wmv>"?:\Tools\VLC\vlc.exe"
2=+"Media Player Classic HC" avi;flv;m2ts;mkv;mov;mp4;mpg;mpeg;ts;vob;wmv>"?:\Tools\Media Player Classic HC\mpc-hc.exe"
3=+"EditPlus" ini;cs;nfo;txt;uew;xys>"?:\Tools\EditPlus\EditPlus.exe"
4=+"UltraEdit" ini;cs;nfo;txt;uew;xys>"?:\Tools\UltraEdit\UltraEditPortable.exe"


Use the new file and duplicate it to save all the different configs that you need.

4. Save the source code to an .xys file and put it on e.g. a user configurable button

Code: Select all

/* 12.01.2012, Replace user defined associations in the XYplorer.ini file
 ::load "<xyscripts>\.snippets\ReplaceAssociations.xys";
*/

	// Enter the path / folder name where your associations files are stored:
	$AssocPath = "<xydata>\Associations";

	// ---------------------------------------------------------------
	// Don't change anything below unless you know what you're doing
	$XYConfig = "<xydata>\XYplorer.ini";
	$LoadConfig = readfile("$XYConfig", t);

	$Files = listfolder("$AssocPath");
	$SelectedSet = inputselect("Choose your file set:", "$Files", "|");
	$ReplaceWith = readfile("$SelectedSet", t);

	// Replace old with new file associations
	$NewConfig = regexreplace($LoadConfig, "(\[FileAssoc\][\s|\S]*?<crlf>)<crlf>", "$ReplaceWith");

	// Confirm replace or quit
	end confirm("Restart XYplorer with new configuration?") == 0, "Aborted";

	// Save the new XYplorer config file
	writefile("$XYConfig", "$NewConfig", o, tu);

	// Restart XYplorer without saving the current config
	#190;
Second point:

You can do something similar, create different .reg files and import them afterwards (with regedit /s)
One of my scripts helped you out? Please donate via Paypal

Post Reply