Created
November 3, 2012 17:02
-
-
Save lluchs/4007915 to your computer and use it in GitHub Desktop.
Convert Windows-.lnk files to symlinks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dir.glob '*.lnk' do |file| | |
| content = File.read file, mode: 'rb' | |
| # You might need a different regex. | |
| result = content.match(/C:[\w\\ ]+\.\w+/) | |
| if result | |
| target = result[0] | |
| `cmd /c mklink "#{File.basename(target)}" "#{target}"` | |
| else | |
| puts 'Error in ' + file | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment