Convert .lnk shortcut to symlink

Related to my Web gallery solution and Symlink forest generator, I wanted a way to convert Windows-style shortcuts (.lnk files) to symlinks.

Apparently I am the first person to publish this research on the Internet. Nobody else in the world has discussed performing this operation. It’s probably foolhardy, but it was technically interesting.

I wrote the shortcut2symlink python library and cli tool.

Overview

A Windows client is used to maintain a website/ subdirectory of files that will be processed using the gallery project. To facilitate the process of preparing files for this website/ subdirectory, particularly over a wireless network connection, users have been instructed to just make Windows-style shortcuts (using CTRL+SHIFT dragging) in the website subdirectory in whatever layout desired.

This project includes components that will scan the designated directory for .lnk files anywhere underneath, and interpret their targets, and generate symlinks in place of the .lnk files. Unfortunately my scanner (inotify) is slightly flaky, and sometimes I still need to manually run the s2s.py command directly.

The point of using symlinks in this case is to reduce the disk usage and number of duplicate files and directories. To SMB users on the Windows client, the symlink files will look like copies, but that is acceptable because the main focus is the gallery generation for the web server.

Reason for existence

Reduce disk space by removing duplicate files, while still having a whole directory structure readable by the gallery solution for generating static site pages, and while making it easy for wireless network users to “manage” links to files at least initially.

Example usage

For the inotify script:

/mnt/public/Support/Programs/shortcuts/s2s-inotify.sh /mnt/public/Images/username1-photos/website

And for manually running:

/mnt/public/Support/Programs/shortcuts/s2s.py --indir /mnt/public/Images/username1-photos/website --apply --debug 8 --delete

References

Weblinks

.lnk format reference