strayge / pylnk

Python library for reading and writing Windows shortcut files (.lnk). Python 3 only.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a way to print all link properties using command line only

andry81 opened this issue · comments

The utility can be used to print link attributes:

pylnk3 p link.lnk __dict__
pylnk3 p link.lnk _shell_item_id_list.__dict__

But some inner attributes is not accessible:

pylnk3 p link.lnk _shell_item_id_list.items.__dict__
pylnk3 p link.lnk _shell_item_id_list.items[0]

Is there a way to do it from the command line only?

I don't think so.

Can you explain use case needed to direct access inner fields?

Probably can be fixed with json-formatted parsing output?

Can you explain use case needed to direct access inner fields?

To print all fields from script recursively.

check it out https://github.com/strayge/pylnk/tree/cli_attributes_with_indexes

should work like this:

❯ py pylnk3.py p tests/examples/local_file.lnk _shell_item_id_list.items.0.guid    
{20D04FE0-3AEA-1069-A2D8-08002B30309D}

check it out cli_attributes_with_indexes

To iterate recursively needs the size attribute :)

json branch contains initial support for parsing output in json format

usage:

❯ pylnk3 parse tests/examples/desktop.lnk --json
{
    "description": null,
    "relative_path": "..\\Desktop",
    "work_dir": null,
    "arguments": null,
    "icon": null,
    "window_mode": "Normal",
    "hotkey": "",
    "creation_time": "2017-08-31T22:00:40.224062",
    "modification_time": "2019-06-18T00:22:21.135277",
    "access_time": "2019-05-26T22:27:49.979498",
    "file_size": 8192,
    "link_flags": {
        "HasLinkTargetIDList": true,
        ...
        "PreferEnvironmentPath": false,
        "KeepLocalIDListForUNCTarget": false
    },
    "shell_item_id_list": {
        "items": []
    },
    ...
}

Does it cover your use case?

Why the json branch has not been merged to main branch?