Skip to content

associate file types with the editor #286

Open
@gdementen

Description

@gdementen

Notably .h5 but probably also feather, .laf and possibly others

Here are two commands, which when run in an Administrator launched command prompt, achieves that for .h5 files.

assoc .h5=HDF5
ftype HDF5="C:\soft\Miniconda3\pythonw.exe" "C:\soft\Miniconda3\cwp.py" "C:\soft\Miniconda3" "C:\soft\Miniconda3\pythonw.exe" "C:\soft\Miniconda3\Scripts\larray-editor-script.py" "%1"

I wonder if cwp.py is even necessary when larrayenv has been installed in the base environment. IF not, this would simplify to:

ftype HDF5="C:\soft\Miniconda3\pythonw.exe" "C:\soft\Miniconda3\Scripts\larray-editor-script.py" "%1"

Or, for a specific conda environment:

ftype HDF5="C:\soft\Miniconda3\pythonw.exe" "C:\soft\Miniconda3\cwp.py" "C:\soft\Miniconda3\envs\py312larrayenv" "C:\soft\Miniconda3\envs\py312larrayenv\pythonw.exe" "C:\soft\Miniconda3\envs\py312larrayenv\Scripts\larray-editor-script.py" "%1"

yvda also suggested going via registry, which might provide more options:

Windows Registry Editor Version 5.00
 
; Associate .h5 files with a custom handler
[HKEY_CLASSES_ROOT\.h5]
@="h5file"
"Content Type"="application/x-hdf5"
 
; Define h5file as a recognized file type
[HKEY_CLASSES_ROOT\h5file]
@="HDF5 File"
 
; Add an "Open" command to h5file
[HKEY_CLASSES_ROOT\h5file\shell\open]
@="Open with Larray Editor"
 
[HKEY_CLASSES_ROOT\h5file\shell\open\command]
@="\"C:\\soft\\Miniconda3\\pythonw.exe\" \"C:\\soft\\Miniconda3\\cwp.py\" \"C:\\soft\\Miniconda3\" \"C:\\soft\\Miniconda3\\pythonw.exe\" \"C:\\soft\\Miniconda3\\Scripts\\larray-editor-script.py\" \"%1\""

save file.reg -> cmd (as admin) -> regedit /s "c:/file/file.reg"

According to https://superuser.com/a/794467, using the registry option could also be used to change the icon for those files, which would be nicer than having the Python icon we now get.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions