Find the answer to your Linux question:
Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 33
Please, forget about the version above and test this one instead: Code: #!/bin/bash ###################################################################### # # # lnk2symlink by jesus.guerrero.botella at gmail dot com, # # search for windows .lnk ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #21
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513

    Please, forget about the version above and test this one instead:

    Code:
    #!/bin/bash
    
    ######################################################################
    #                                                                    #
    # lnk2symlink by jesus.guerrero.botella at gmail dot com,            #
    # search for windows .lnk files on a given directory, and creates    #
    # symlinks according to the info contained on those files            #
    #                                                                    #
    # This script is provided without any kind of implicit or explicit   #
    # guarantee, and is licensed under the GNU General Public License v3 #
    # or later if available. More about licenses on the following URL:   #
    #                                                                    #
    # http://www.gnu.org/licenses/licenses.html                          #
    #                                                                    #
    ######################################################################
    
    VERSION=20101213
    PROGRAM_NAME=$(basename $0)
    
    die() {
    	case $1 in
    		non_linkable_fs)
    			echo "The target filesystem doesn't support symlinks."
    			exit 11
    			;;
    		ln_error)
    			echo "Undefined error while symlinking."
    			exit 10
    			;;
    		number_of_args)
    			echo "Incorrect number of arguments."
    			echo "Usage: $0 origin_dir destination_dir"
    			exit 12
    			;;
    		could_not_create_dest)
    			echo "Couldn't create destination directory."
    			exit 13
    			;;
    		orig_not_found)
    			echo "Origin directory not found or not readable."
    			exit 14
    			;;
    		could_not_create_symlink)
    			echo "Couldn't create symlink."
    			exit 15
    			;;
    		*)
    			echo "Undefined error."
    			exit 20
    			;;
    	esac
    }
    
    case $# in
    	2)
    		ORIG="$1"
    		DEST="$2"
    		;;
    	*)
    		die number_of_args
    		;;
    esac
    
    # Test for the existence of the required directories
    [ ! -d "$DEST" ] && mkdir "$DEST"
    [ ! -d "$DEST" ] && die could_not_create_dest
    [ ! -d "$ORIG" ] && die orig_not_found
    
    # Test the symlinking tool, if it fails then probably
    # your FS doesn't support soft links.
    TESTLN="$DEST/test-$RANDOM$RANDOM$RANDOM$RANDOM"
    ln -s "$HOME" "$TESTLN" > /dev/null 2>&1 || die non_linkable_fs
    rm -f "$TESTLN"
    
    echo
    echo "Where to look for .lnk files:"
    echo "  \"$ORIG"
    echo "Where to look put symlinks:"
    echo "  \"$DEST"
    echo "Finding files, this may take a while"
    echo "------------------------------------"
    
    find "$ORIG" -iname '*.lnk' | while read LNK_FILE
    do
    	echo "Found: \"$LNK_FILE\""
    	CANDIDATE_STRING=$(strings "$LNK_FILE" | grep ':\\')
    	SYMLINK_NAME=$(echo $CANDIDATE_STRING | sed -e 's#.*\\#'"$DEST/"'#' )
    	if [ -L "$SYMLINK_NAME" ]; then
    		echo "\"$SYMLINK_NAME\" do exist, and it's a symlink, skipping."
    	else
    		if [ -r "$SYMLINK_NAME" ]; then
    			echo "File with the same name detected, but it's not a symlink."
    			echo "I will add a RANDOM suffix to the symlink name."
    			SYMLINK_NAME="${SYMLINK_NAME}-${RANDOM}"
    		fi
    		echo "Running: ln -s \"$LNK_FILE\" \"$SYMLINK_NAME\""
    		ln -s "$LNK_FILE" "$SYMLINK_NAME" || die could_not_symlink
    	fi
    done
    It should be simpler to understand and get working. The usage is

    Code:
    ./scriptname origin_dir destination_dir
    It tests for the existence of both directories and create the destination if needed and possible. Otherwise it should error gracefully. Be very careful. I coded this in a hurry and it's completely untested. It shouldn't be dangerous but you know...

  2. #22
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Chapter 1 - The Exclamation
    Chapter 2 - How I Discovered It
    Chapter 3 - How it Works
    Chapter 4 - Still Willing to Help with This Script
    Chapter 5 - Summary of Solution


    The Exclamation

    USING .LNK FILES (Windows Shortcuts) IS BUILT INTO LUCID 10.04 (VIA WINE) AND NOBODY TOLD US !!!!! ARGGGHHHHHHHHHHHHHHHHHHHHH !!!!
    :-)
    :-)

    Ok, that's not an "I'm mad" string of capitals; that's an "I'm relieved" (after about fifteen hours of work and searching) string of capitals. I just, on accident, figured out how this functionality is already built into Ubuntu Lucid 10.04 and either it's not documented or it's too hard to find amongst the avenues that I've been chasing through.

    How I Discovered It

    One of the very first things I had tried a few days ago, on about the first hour that I was working on this issue, was to see if WINE could open up these .lnk files. Well that didn't work. I had even looked at the "Drives" tab in the "Configure WINE" options. However since I am still an Ubuntu and WINE newbie I guess "it" didn't click.

    It wasn't until about the twelfth or thirteenth hour in troubleshooting the workings of this sym2lnk script that I stumbled back through the "Drives" tab in the "Configure WINE" options. And partly for the sake of troubleshooting and partly out of a sense of nostalgia I set my external drive as the target for it's old 'windows' drive letter "G:\" in aforementioned "Drives" tab.

    How it Works

    Well that didn't help the script any. However what I just discovered (a couple of troubleshooting hours later) is that I had inadvertently fixed WINE's apparent built ability to handle Window's shortcuts. Now I can follow a .LNK file with a "Right-Click" on it in Nautilus and select "Open with WINE Windows Program Loader" (which opens up the WINE file manager).


    Still Willing to Help with This Script

    But lastly I want to say that I am still willing to help with the testing of the script that this thread is centered on for a couple of reasons. Namely I still see it would be useful for those that are having trouble with WINE or would, for various reasons, still want to have native Linux Symlinks for their files. Even after this BASH Script is working well I will very likely continue to see this through to other forums and get it working in Nautilus. Again I do see value in this little tool and think it's important to give back to the Linux community in some small way for all the cool free stuff that is allowing me to create a machine I am be productive on.

    Summary of Solution

    1) Go to the “Drives” tab in the “Configure WINE” options.
    2) Under “Drive Mappings” add a drive. The letter should be the same as what the drive used to be in windows.
    3) Don’t forget to look at “Path” in the middle of this dialog box and map to this letter to the appropriate drive.


    God bless !
    Last edited by tg3793; 12-14-2010 at 03:18 AM.

  3. #23
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Quote Originally Posted by i92guboj View Post
    Please, forget about the version above and test this one instead:

    It should be simpler to understand and get working. The usage is

    Code:
    ./scriptname origin_dir destination_dir
    It tests for the existence of both directories and create the destination if needed and possible. Otherwise it should error gracefully. Be very careful. I coded this in a hurry and it's completely untested. It shouldn't be dangerous but you know...
    * Feedback *

    Got three more broken links. I've attached the three .lnk shortcuts in a zipfile here just in case you would find them useful to code against.

    I'm going to use the same -x trick that you showed me. You'll find the output below.

    $ ./lnk2sym Test Test
    + VERSION=20101213
    ++ basename ./lnk2sym
    + PROGRAM_NAME=lnk2sym
    + case $# in
    + ORIG=Test
    + DEST=Test
    + '[' '!' -d Test ']'
    + '[' '!' -d Test ']'
    + '[' '!' -d Test ']'
    + TESTLN=Test/test-24790167662858326501
    + ln -s /home/scribe Test/test-24790167662858326501
    + rm -f Test/test-24790167662858326501
    + echo

    + echo 'Where to look for .lnk files:'
    Where to look for .lnk files:
    + echo ' "Test'
    "Test
    + echo 'Where to look put symlinks:'
    Where to look put symlinks:
    + echo ' "Test'
    "Test
    + echo 'Finding files, this may take a while'
    Finding files, this may take a while
    + echo ------------------------------------
    ------------------------------------
    + find Test -iname '*.lnk'
    + read LNK_FILE
    + echo 'Found: "Test/Personal New.Proj (on I).lnk"'
    Found: "Test/Personal New.Proj (on I).lnk"
    ++ strings 'Test/Personal New.Proj (on I).lnk'
    ++ grep ':\\'
    + CANDIDATE_STRING='/G:\
    G:\I\Tim\Personal\Proj\New.Proj'
    ++ echo '/G:\' 'G:\I\Tim\Personal\Proj\New.Proj'
    ++ sed -e 's#.*\\#Test/#'
    + SYMLINK_NAME=Test/New.Proj
    + '[' -L Test/New.Proj ']'
    + '[' -r Test/New.Proj ']'
    + echo 'Running: ln -s "Test/Personal New.Proj (on I).lnk" "Test/New.Proj"'
    Running: ln -s "Test/Personal New.Proj (on I).lnk" "Test/New.Proj"
    + ln -s 'Test/Personal New.Proj (on I).lnk' Test/New.Proj
    + read LNK_FILE
    + echo 'Found: "Test/Tech TOOLS_General (on J).lnk"'
    Found: "Test/Tech TOOLS_General (on J).lnk"
    ++ strings 'Test/Tech TOOLS_General (on J).lnk'
    ++ grep ':\\'
    + CANDIDATE_STRING='/G:\
    G:\J\Installs\- Blip 01\Tech\TOOLS (General)'
    ++ echo '/G:\' 'G:\J\Installs\-' Blip '01\Tech\TOOLS' '(General)'
    ++ sed -e 's#.*\\#Test/#'
    + SYMLINK_NAME='Test/TOOLS (General)'
    + '[' -L 'Test/TOOLS (General)' ']'
    + '[' -r 'Test/TOOLS (General)' ']'
    + echo 'Running: ln -s "Test/Tech TOOLS_General (on J).lnk" "Test/TOOLS (General)"'
    Running: ln -s "Test/Tech TOOLS_General (on J).lnk" "Test/TOOLS (General)"
    + ln -s 'Test/Tech TOOLS_General (on J).lnk' 'Test/TOOLS (General)'
    + read LNK_FILE
    + echo 'Found: "Test/Videos_Faith (on J).lnk"'
    Found: "Test/Videos_Faith (on J).lnk"
    ++ strings 'Test/Videos_Faith (on J).lnk'
    ++ grep ':\\'
    + CANDIDATE_STRING='/G:\
    G:\J\Videos\Faith'
    ++ echo '/G:\' 'G:\J\Videos\Faith'
    ++ sed -e 's#.*\\#Test/#'
    + SYMLINK_NAME=Test/Faith
    + '[' -L Test/Faith ']'
    + '[' -r Test/Faith ']'
    + echo 'Running: ln -s "Test/Videos_Faith (on J).lnk" "Test/Faith"'
    Running: ln -s "Test/Videos_Faith (on J).lnk" "Test/Faith"
    + ln -s 'Test/Videos_Faith (on J).lnk' Test/Faith
    + read LNK_FILE


    Let me know what I can do next to help you get this working.
    Attached Files Attached Files

  4. #24
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    I've found a couple of particularly important needs remaining for this script. Although the WINE trick is useful for navigating my old links, I still have a hard time 'doing' anything with those files.

    Namely copying and pasting files when I need to. Thanks again and look forward to hearing back from you on this.

  5. #25
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    It's what it has to do things in a rush. I found a fundamental flaw in the script which renders it useless, because links end pointing to the lnk files, which is not the intended purpose.

    This is not due to the script being buggy, but due to my whole base being flawed.

    As you said in other post above, for this to work I would first need to find what "G:\" (or whatever) means in Linux. And there's no easy way to guess this, other than using "find" and hoping that the file name is unique in your system, which probably is not the usual case.

    I knew there had to be a reason why I hardcoded the ~/.wine/drive_c path in my original script. That's why.

    So, this requires probably more time than I can devote right now to scripting, unless someone can provide me with an easy way to guess the path to the right file.

    Sorry.

  6. #26
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Quote Originally Posted by i92guboj View Post
    As you said in other post above, for this to work I would first need to find what "G:\" (or whatever) means in Linux. And there's no easy way to guess this, other than using "find" and hoping that the file name is unique in your system, which probably is not the usual case.

    So, this requires probably more time than I can devote right now to scripting, unless someone can provide me with an easy way to guess the path to the right file.

    .
    Why guess? ... How about an interactive script that pauses to ask you to type the name of the drive?

    It could even get a little 'smart'. Perhaps it could say something like "You have selected ten (variable number) Windows Shortcuts to convert. If all of these Shortcuts point to the same drive please type the name of that drive now."

    In my case I would type "sdb1" (or am I just suppose to type sdb?)

    I'm simply guessing that Linux scripting can do at least as much as the DOS Batch file stuff I used to do a little of about a decade ago (I was primarily a manager). So calling a user for input should be a fairly easy matter?

    What do you think?

  7. #27
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by tg3793 View Post
    Why guess? ... How about an interactive script that pauses to ask you to type the name of the drive?

    It could even get a little 'smart'. Perhaps it could say something like "You have selected ten (variable number) Windows Shortcuts to convert. If all of these Shortcuts point to the same drive please type the name of that drive now."

    In my case I would type "sdb1" (or am I just suppose to type sdb?)

    I'm simply guessing that Linux scripting can do at least as much as the DOS Batch file stuff I used to do a little of about a decade ago (I was primarily a manager). So calling a user for input should be a fairly easy matter?

    What do you think?
    Of course we could that, but then, that wouldn't differ much from doing the symlinks manually.

    The scripting capabilities of bash (or any other posix shell, nothing to do with Linux itself really) are light-years ahead those from command.com. 4dos did a bit of a better job, though, but that wasn't part of DOS but a 3rd party tool.

    But that doesn't solve the issue at hand. I will however try to design an intermediate solution just to close the case. Stay tuned.

  8. #28
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Here you are:

    Code:
    #!/bin/bash
    
    ######################################################################
    #                                                                    #
    # lnk2symlink by jesus.guerrero.botella at gmail dot com,            #
    # search for windows .lnk files on a given directory, and creates    #
    # symlinks according to the info contained on those files            #
    #                                                                    #
    # This script is provided without any kind of implicit or explicit   #
    # guarantee, and is licensed under the GNU General Public License v3 #
    # or later if available. More about licenses on the following URL:   #
    #                                                                    #
    # http://www.gnu.org/licenses/licenses.html                          #
    #                                                                    #
    ######################################################################
    
    VERSION=20101213
    PROGRAM_NAME=$(basename $0)
    
    die() {
    	case $1 in
    		non_linkable_fs)
    			echo "The target filesystem doesn't support symlinks."
    			exit 11
    			;;
    		ln_error)
    			echo "Undefined error while symlinking."
    			exit 10
    			;;
    		number_of_args)
    			echo
    			echo "[E] Incorrect number of arguments."
    			echo "Usage: $0 origin_dir destination_dir dos_drive_basedir"
    			echo
    			echo " origin_directory is the directory containing the .lnk"
    			echo " files. It will be recursed."
    			echo
    			echo " destination_directory is the directory where you want"
    			echo " the symlinks to be created."
    			echo
    			echo " dos_drive_basedir is the linux directory that will be"
    			echo " used in place of \"C:\\\" (or whatever drive) when looking"
    			echo " for the link destination."
    			echo
    			echo "Typical usage case:"
    			echo " "$(basename $0)" ~/Desktop/ ~/bin/ ~/.wine/drive_c/"
    			echo
    			exit 12
    			;;
    		could_not_create_dest)
    			echo "Couldn't create destination directory."
    			exit 13
    			;;
    		orig_not_found)
    			echo "Origin directory not found or not readable."
    			exit 14
    			;;
    		could_not_create_symlink)
    			echo "Couldn't create symlink."
    			exit 15
    			;;
    		*)
    			echo "Undefined error."
    			exit 20
    			;;
    	esac
    }
    
    case $# in
    	3)
    		ORIG="$1"
    		DEST="$2"
    		DOS_DRIVE="$3"
    		;;
    	*)
    		die number_of_args
    		;;
    esac
    
    # Test for the existence of the required directories
    [ ! -d "$DEST" ] && mkdir "$DEST"
    [ ! -d "$DEST" ] && die could_not_create_dest
    [ ! -d "$ORIG" ] && die orig_not_found
    
    # Test the symlinking tool, if it fails then probably
    # your FS doesn't support soft links.
    TESTLN="$DEST/test-$RANDOM$RANDOM$RANDOM$RANDOM"
    ln -s "$HOME" "$TESTLN" > /dev/null 2>&1 || die non_linkable_fs
    rm -f "$TESTLN"
    
    echo
    echo "Where to look for .lnk files:"
    echo "  \"$ORIG"
    echo "Where to look put symlinks:"
    echo "  \"$DEST"
    echo "The DOS base drive is:"
    echo "  \"$DOS_DRIVE"
    echo
    echo "Finding files, this may take a while..."
    echo
    
    find "$ORIG" -iname '*.lnk' | while read LNK_FILE
    do
    	echo "[*] Found: \"$LNK_FILE\""
    	CANDIDATE_STRING=$(strings "$LNK_FILE" | grep ':\\')
    	LINUX_PATH_TO_EXE_FILE=$(echo "$CANDIDATE_STRING" | \
    		sed -e 's#.*:\\#'"$DOS_DRIVE"'#' | \
    		sed -e 's#\\#\/#g' )
    	SYMLINK_NAME="$DEST"/$(basename "$LINUX_PATH_TO_EXE_FILE")
    	if [ ! -L "$SYMLINK_NAME" ]; then
    		if [ -r "$SYMLINK_NAME" ]; then
    			echo "[i] File with the same name detected, but it's not a symlink."
    			echo "[i] I will add a RANDOM suffix to the symlink name."
    			SYMLINK_NAME="${SYMLINK_NAME}-${RANDOM}"
    		fi
    	fi
    	if [ -r "$LINUX_PATH_TO_EXE_FILE" ]; then
    		echo "[i] Running: ln -nfs \"$LINUX_PATH_TO_EXE_FILE\" \"$SYMLINK_NAME\""
    		ln -nfs "$LINUX_PATH_TO_EXE_FILE" "$SYMLINK_NAME" || die could_not_symlink
    	else
    		echo "[E] This .lnk file points to a file that doesn't exist."
    		echo "[E] Couldn't create this symlink, sorry."
    	fi
    done
    The result from running it:

    Code:
    $ lnk2symlink ../Desktop/ ../foobar ~/.wine/drive_c/; ls -l ../foobar/
    
    Where to look for .lnk files:
      "../Desktop/
    Where to look put symlinks:
      "../foobar
    The DOS base drive is:
      "/home/i92guboj/.wine/drive_c/
    
    Finding files, this may take a while...
    [*] Found: "../Desktop/WinSetupFromUSB.lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "../Desktop/Ares.lnk"
    [i] Running: ln -nfs "/home/i92guboj/.wine/drive_c/Archivos de programa/Ares/Ares.exe" "../foobar/Ares.exe"[*] Found: "../Desktop/Spotify.lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "../Desktop/Guitar Pro 5.lnk"
    [i] Running: ln -nfs "/home/i92guboj/.wine/drive_c/Archivos de programa/Guitar Pro 5/GP5.exe" "../foobar/GP5.exe"
    total 8,0K
    lrwxrwxrwx 1 i92guboj i92guboj 63 dic 16 16:08 Ares.exe -> /home/i92guboj/.wine/drive_c/Archivos de programa/Ares/Ares.exe
    lrwxrwxrwx 1 i92guboj i92guboj 70 dic 16 16:08 GP5.exe -> /home/i92guboj/.wine/drive_c/Archivos de programa/Guitar Pro 5/GP5.exe

  9. #29
    Just Joined!
    Join Date
    Nov 2010
    Location
    Philippines
    Posts
    29
    Take your time on getting back with me on this. You've been kind enough to look at this and I don't want you to feel any pressure for something that is 100% volunteer.

    And if you tell me that you are really even too busy to get back to this anytime in the next couple of week then just give me the green light and I'll post this around some other forums to solicit some additional help (if at all possible for me to do at all). I'm quite appreciative of what you've done here. This practical experience will certainly help me to eventually learn how to do this one day myself. Thank you.

    And I've done a little searching on you around the net so I can tell you are quite busy guy and you have been of quite a bit of help to lots of people.

    Here is my latest feedback from this effort to use this.

    I had put the "lnk shortcuts" in a directory called "lnks" and of course the directories that I 'knew' that they should point to are on all the original drive this time; in my case "~/.wine/dosdevices/g:".

    ./lnk2sym ~/.wine/dosdevices/g:/lnks Test ~/.wine/dosdevices/g:/

    Where to look for .lnk files:
    "/home/scribe/.wine/dosdevices/g:/lnks
    Where to look put symlinks:
    "Test
    The DOS base drive is:
    "/home/scribe/.wine/dosdevices/g:/

    Finding files, this may take a while...
    [*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/ExecDirectNewProj (on I).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/I (Gold).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/Images 2009.lnk"
    [i] Running: ln -nfs "/home/scribe/.wine/dosdevices/g:/" "Test/g:"[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/J (installs).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/K (mp3).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.


    It was interesting at least, that though this script still didn't work 100%, it did successfully create '1' symlink in the target directory (though pointing to the wrong place). As you can from the output above it took "Images 2009.lnk" and created a symlink that just pointed to the root of the drive "g:\"

    And just as before I've attached a zip of the lnk files in hopes that might assist you in some way. Thanks.
    Attached Files Attached Files

  10. #30
    Linux Guru
    Join Date
    Nov 2007
    Location
    Córdoba (Spain)
    Posts
    1,513
    Quote Originally Posted by tg3793 View Post
    Take your time on getting back with me on this. You've been kind enough to look at this and I don't want you to feel any pressure for something that is 100% volunteer.
    Don't worry, I don't feel any pressure, I enjoy this, it's just that I don't have much free time.

    Here is my latest feedback from this effort to use this.

    I had put the "lnk shortcuts" in a directory called "lnks" and of course the directories that I 'knew' that they should point to are on all the original drive this time; in my case "~/.wine/dosdevices/g:".

    ./lnk2sym ~/.wine/dosdevices/g:/lnks Test ~/.wine/dosdevices/g:/

    Where to look for .lnk files:
    "/home/scribe/.wine/dosdevices/g:/lnks
    Where to look put symlinks:
    "Test
    The DOS base drive is:
    "/home/scribe/.wine/dosdevices/g:/

    Finding files, this may take a while...
    [*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/ExecDirectNewProj (on I).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/I (Gold).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/Images 2009.lnk"
    [i] Running: ln -nfs "/home/scribe/.wine/dosdevices/g:/" "Test/g:"[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/J (installs).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.[*] Found: "/home/scribe/.wine/dosdevices/g:/lnks/K (mp3).lnk"
    [E] This .lnk file points to a file that doesn't exist.
    [E] Couldn't create this symlink, sorry.


    It was interesting at least, that though this script still didn't work 100%, it did successfully create '1' symlink in the target directory (though pointing to the wrong place). As you can from the output above it took "Images 2009.lnk" and created a symlink that just pointed to the root of the drive "g:\"

    And just as before I've attached a zip of the lnk files in hopes that might assist you in some way. Thanks.
    There was a small bug related to paths. Please, try the corrected script and see if it gets you any further:

    Code:
    #!/bin/bash
    
    ######################################################################
    #                                                                    #
    # lnk2symlink by jesus.guerrero.botella at gmail dot com,            #
    # search for windows .lnk files on a given directory, and creates    #
    # symlinks according to the info contained on those files            #
    #                                                                    #
    # This script is provided without any kind of implicit or explicit   #
    # guarantee, and is licensed under the GNU General Public License v3 #
    # or later if available. More about licenses on the following URL:   #
    #                                                                    #
    # http://www.gnu.org/licenses/licenses.html                          #
    #                                                                    #
    ######################################################################
    
    VERSION=20101220
    PROGRAM_NAME=$(basename $0)
    
    die() {
    	case $1 in
    		non_linkable_fs)
    			echo "The target filesystem doesn't support symlinks."
    			exit 11
    			;;
    		ln_error)
    			echo "Undefined error while symlinking."
    			exit 10
    			;;
    		number_of_args)
    			echo
    			echo "[E] Incorrect number of arguments."
    			echo "Usage: $0 origin_dir destination_dir dos_drive_basedir"
    			echo
    			echo " origin_directory is the directory containing the .lnk"
    			echo " files. It will be recursed."
    			echo
    			echo " destination_directory is the directory where you want"
    			echo " the symlinks to be created."
    			echo
    			echo " dos_drive_basedir is the linux directory that will be"
    			echo " used in place of \"C:\\\" (or whatever drive) when looking"
    			echo " for the link destination."
    			echo
    			echo "Typical usage case:"
    			echo " "$(basename $0)" ~/Desktop/ ~/bin/ ~/.wine/drive_c/"
    			echo
    			exit 12
    			;;
    		could_not_create_dest)
    			echo "Couldn't create destination directory."
    			exit 13
    			;;
    		orig_not_found)
    			echo "Origin directory not found or not readable."
    			exit 14
    			;;
    		could_not_create_symlink)
    			echo "Couldn't create symlink."
    			exit 15
    			;;
    		*)
    			echo "Undefined error."
    			exit 20
    			;;
    	esac
    }
    
    case $# in
    	3)
    		ORIG="$1"
    		DEST="$2"
    		DOS_DRIVE="$3"
    		;;
    	*)
    		die number_of_args
    		;;
    esac
    
    # Test for the existence of the required directories
    [ ! -d "$DEST" ] && mkdir "$DEST"
    [ ! -d "$DEST" ] && die could_not_create_dest
    [ ! -d "$ORIG" ] && die orig_not_found
    
    # Test the symlinking tool, if it fails then probably
    # your FS doesn't support soft links.
    TESTLN="$DEST/test-$RANDOM$RANDOM$RANDOM$RANDOM"
    ln -s "$HOME" "$TESTLN" > /dev/null 2>&1 || die non_linkable_fs
    rm -f "$TESTLN"
    
    echo
    echo "Where to look for .lnk files:"
    echo "  \"$ORIG\""
    echo "Where to look put symlinks:"
    echo "  \"$DEST\""
    echo "The DOS base drive is:"
    echo "  \"$DOS_DRIVE\""
    echo
    echo "Finding files, this may take a while..."
    echo
    
    find "$ORIG" -iname '*.lnk' | while read LNK_FILE
    do
    	echo "[*] Found: \"$LNK_FILE\""
    	CANDIDATE_STRING=$(strings "$LNK_FILE" | grep ':\\')
    	LINUX_PATH_TO_EXE_FILE=$(echo "$CANDIDATE_STRING" | \
    		sed -e 's#.*\n##g' | \
    		sed -e 's#.*:\\#'"$DOS_DRIVE"'\/#' | \
    		sed -e 's#\\#\/#g' )
    		echo "[i] The candidate file string is:"
    		echo "[i] \"$LINUX_PATH_TO_EXE_FILE\""
    	SYMLINK_NAME="$DEST"/$(basename "$LINUX_PATH_TO_EXE_FILE")
    	if [ ! -L "$SYMLINK_NAME" ]; then
    		if [ -r "$SYMLINK_NAME" ]; then
    			echo "[i] File with the same name detected, but it's not a symlink."
    			echo "[i] I will add a RANDOM suffix to the symlink name."
    			SYMLINK_NAME="${SYMLINK_NAME}-${RANDOM}"
    		fi
    	fi
    	if [ -r "$LINUX_PATH_TO_EXE_FILE" ]; then
    		echo "[i] Running: ln -nfs \"$LINUX_PATH_TO_EXE_FILE\" \"$SYMLINK_NAME\""
    		ln -nfs "$LINUX_PATH_TO_EXE_FILE" "$SYMLINK_NAME" || die could_not_symlink
    	else
    		echo "[E] This .lnk file points to a file that doesn't exist."
    		echo "[E] Couldn't create this symlink, sorry."
    	fi
    done

Page 3 of 4 FirstFirst 1 2 3 4 LastLast

Posting Permissions

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