Results 1 to 7 of 7
I have large number of files I want to copy from my Windows machine to a Linux Asus PC. The trouble is that there is extensive cross-referencing between the Windows ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 07-27-2008 #1Just Joined!
- Join Date
- Jul 2008
- Posts
- 4
Converting Windows shortcuts into Linux links
I have large number of files I want to copy from my Windows machine to a Linux Asus PC. The trouble is that there is extensive cross-referencing between the Windows file using shortcuts (.lnk files).
Does anyone know of a utility or script that can process lnk files and convert them to proper links? I'm hoping to find something repeatable and dependable as the files change frequently on the Windows side and will need copying to Linux frequently.
TIA
- 07-28-2008 #2Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
I don't know of such a tool, but I could probably write a simple bash script to achieve that effect if I had a .lnk file to see it's internal format (provided that it's a plain text file, which I guess it is).
So, if you provide me with a sample .lnk file I could try to write something (yes, today I am bored :P ).
EDIT: Nevermind, I got one from one of my wine directories. It's a binary file though, I will see what can be done.
- 07-28-2008 #3Just Joined!
- Join Date
- Jul 2008
- Posts
- 4
- 07-28-2008 #4Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
And there you are.
http://jesgue.homelinux.org/scripts/lnk2symlink
It's easy enough to use. No guarantee that it will work (nor any other kind of guarantee for that matter). I hope this helps. I tested it and it successfully read all the lnk files in my wine dirs (65 files) and created the respective linux symlinks. Of course, this will only work if the fs holding the files has support for symlinks (windows fat fs's do not have it). It should be safe to use.
Just put it somewhere in your path and chmod a+x it.
PD: Run it without arguments (or with -h or --help) to see the usage mode. It doesn't do anything until you use -d or --do.
PD: The script uses the tool "strings", part of binutils. It also uses sed and grep internally. Those are the only requirements, they are pretty much standard on most distros, I think.
- 07-29-2008 #5Just Joined!
- Join Date
- Jul 2008
- Posts
- 4
Thanks very much for that. I now have a bit of work to do. binutils isn't installed by default on the Asus PC Eee distro, nor is it in its default list of packages. Bound to be available somewhere though. grep seems to be there and so does sed.
- 07-29-2008 #6Linux Guru
- Join Date
- Nov 2007
- Location
- Córdoba (Spain)
- Posts
- 1,513
You should be able to find binary packages easily. If your distro doesn't ship it, look for a compatible one at pbone.net (good site to find rpm's, that can be uncompressed and used by previously converting them with rpm2targz if your distro doesn't support rpm natively).
- 08-01-2008 #7Just Joined!
- Join Date
- Jul 2008
- Posts
- 4
I found a Debian package and extracted strings and an associated library from it. (binutils is a bit large to put in its entirety on an Asus Eee.)
The script seems to pick up the drive string from the beginning of the lnk file, whereas the lnk file's actual target is further inside the file. However, my copied files always have the same root directory so it was easy to change the script to grep for the target pathname. And I had to change the ".wine" substitutions.
But with just those two changes it all worked fine. So thanks again.
(Although there was one strange occurrence: after processing the entire copied Windows file tree, the file manager was taking five minutes to open any folder. A reboot brought things back to normal, however.)




