Find the answer to your Linux question:
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.
  1. #1
    Just 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

  2. #2
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by jdeacon View Post
    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
    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.

  3. #3
    Just Joined!
    Join Date
    Jul 2008
    Posts
    4
    Quote Originally Posted by i92guboj View Post
    ... 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).

    ...

    Nevermind, I got one from one of my wine directories. It's a binary file though, I will see what can be done.
    That would be fantastic. I think Perl would struggle, so if you can do it with a shell script I shall be delighted and amazed.

    It is indeed a binary file, and quite complicated. There's quite a bit of information on the net.

  4. $spacer_open
    $spacer_close
  5. #4
    Linux 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.

  6. #5
    Just 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.

  7. #6
    Linux 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).

  8. #7
    Just 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.)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •