Page 1 of 1

Open files without extension and unassociated files with same editor

Posted: 27 Aug 2020 13:51
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

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

Posted: 27 Aug 2020 14:24
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";
    }

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

Posted: 28 Aug 2020 16:34
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.

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

Posted: 28 Aug 2020 17:00
by highend
Show a screenshot of the PFA list entries.

Configuration | Other | Features | Portable File Associations / Portable Openwith Menu
is checked?

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

Posted: 28 Aug 2020 17:29
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.

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

Posted: 28 Aug 2020 17:34
by highend
Then post the full path to such a file?

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

Posted: 02 Sep 2020 14:12
by xyfreako
it's working with most files, I wanted to thank you for your help. Hopefully it will be useful to others.