Open files without extension and unassociated files with same editor

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
xyfreako
Posts: 13
Joined: 24 Apr 2020 11:01

Open files without extension and unassociated files with same editor

Post by xyfreako »

I work with a lot of text files that have names without extension or that are generated automatically so have numeric extensions such as .0001.

In other file explorers I could just set a preference so that any file type (not associated to an application or without extension) would open automatically in my selected text editor, in my case Sublime Text.

Is there a way to set this in XYP? Otherwise I am forced to continually go through the windows pop-up menu "how do you want to open this file?".

Thanks in advance

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

Re: Open files without extension and unassociated files with same editor

Post by highend »

Sure, e.g.: an entry (it should be the last one) in PFA (portable file associations):
*>::load "Open via editor.xys";

and create a script with that name in your XY script folder and use something like this:

Code: Select all

$ext = gpc(<curitem>, "ext");
    if ($ext == "" || regexmatches($ext, "\d{3,4}")) {
        run """D:\Tools\EmEditor_x64\EmEditor.exe"" ""<curitem>""";
    } else {
        open <curitem>, "w";
    }
One of my scripts helped you out? Please donate via Paypal

xyfreako
Posts: 13
Joined: 24 Apr 2020 11:01

Re: Open files without extension and unassociated files with same editor

Post by xyfreako »

Thank you highend.

The script works when I test it stand-alone, but it doesn't seem to work automatically, I still get the prompt to choose the application.

In my PFA list is the only one selected.
Any idea why?

Thanks in advance.

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

Re: Open files without extension and unassociated files with same editor

Post by highend »

Show a screenshot of the PFA list entries.

Configuration | Other | Features | Portable File Associations / Portable Openwith Menu
is checked?
One of my scripts helped you out? Please donate via Paypal

xyfreako
Posts: 13
Joined: 24 Apr 2020 11:01

Re: Open files without extension and unassociated files with same editor

Post by xyfreako »

Ok it's working now!

I just hadn't noticed that the PFA list entries had an OK button, so the entry was never saved!

However, do you know why it's not working on all files? I am connected to some network drives and I still get that pesky prompt on certain files without extension. I can't seem to find a pattern.

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

Re: Open files without extension and unassociated files with same editor

Post by highend »

Then post the full path to such a file?
One of my scripts helped you out? Please donate via Paypal

xyfreako
Posts: 13
Joined: 24 Apr 2020 11:01

Re: Open files without extension and unassociated files with same editor

Post by xyfreako »

it's working with most files, I wanted to thank you for your help. Hopefully it will be useful to others.

Post Reply