Results 1 to 3 of 3

Thread: need to correct where 1000's of Aliases are pointing

  1. #1
    MDL Novice
    Join Date
    22 Dec 2016
    Posts
    3
    Thanks Information

    Exclamation need to correct where 1000's of Aliases are pointing

    Hi,
    I used Aperture for several years, and now use Lightroom.
    The way I exported my pictures from Aperture generated a lot of duplicates.

    I am using TidyUp to deduplicate, and it can generate Aliases for me.
    The issue is I used a local SSD connected to my mac running El Capitan,
    Then I moved the files to my NAS thinking the Aliases would change as
    they were moved, but it appears they only automatically change
    if they stay on the same disk (volume).

    Here is a sample of the alias referencing the old location:

    /Volumes/kerryToDeDup/Lightroom2/0025.JPG

    and here is a sample on an alias generated right on the NAS
    which is how I need all of them to be like:

    /Volumes/ps/Lightroom Files/0533.JPG

    almost all of the pictures are in subfolders, like

    /Volumes/kerryToDeDup/Lightroom2/at the park 2015-07-04/dsc0001.JPG
    or now corrected to
    /Volumes/ps/Lightroom Files/at the park 2015-07-04/dsc0001.JPG

    I moved thousands of files before I realized the problem.
    Is there a program to correct the alias' reference,
    or could someone put together a script that will automatically also look in subfolders?

    basically any alias that starts with
    /Volumes/kerryToDeDup/Lightroom2/

    has to be corrected to
    /Volumes/ps/Lightroom Files/


    Thanks for your help and all the best to you in 2017!

    Kerry
    Last edited by hak7; 10 Jan 2017 at 03:17.

  2. #2
    MDL Novice
    Join Date
    22 Dec 2016
    Posts
    3
    Thanks Information

    Default

    OK, I'm learning applescript through some videos. here's a script I copied hours ago, that I am trying to change for my situation.
    I'll keep updating it as I learn more. I will refind where I got the original of this script and give a reference also.
    Here is round 1 ! Sorry, just realized I don't know how to post this as formatted text yet. Will attach a file. I tried uploading a text file (3k size) but it is not saving - I guess I'm too new a user?



    Spoiler: 
    Code:
    tell application "Finder"
        set folder_items to the selection
    end tell
    
    repeat with i from 1 to the count of folder_items
        set this_item to (item i of folder_items) as alias
        set this_info to info for this_item
    
        if class of this_item is alias then
            tell application "Finder"
                set original_file to original item of this_item
                set this_alias_file_name to displayed name of this_item
                set container_folder to container of this_item
    
                set the_path to the POSIX path of (original_file as alias)
                set new_path to my replaceText("/Volumes/kerryToDeDup/Lightroom2/", "/Volumes/ps/Lightroom Files/", the_path)
    
                move this_item to trash
                try
                    make new alias file at container_folder to (POSIX file new_path) with properties {name:this_alias_file_name}
                on error errMsg number errorNumber
                    if errorNumber is -10000 then -- new original file not found, try relinking to old
                        try
                            make new alias file at container_folder to (POSIX file the_path) with properties {name:this_alias_file_name}
                        on error errMsg number errorNumber
                            if errorNumber is -10000 then -- old original not found. link's dead Jim
                                display dialog "The original file for alias " & this_alias_file_name & " was not found."
                            else
                                display dialog "An unknown error occurred:  " & errorNumber as text
                            end if
                        end try
                    else
                        display dialog "An unknown error occurred:  " & errorNumber as text
                    end if
                end try
            end tell
        end if
    end repeat
    
    on replaceText(find, replace, subject)
        set prevTIDs to text item delimiters of AppleScript
        set text item delimiters of AppleScript to find
        set subject to text items of subject
    
        set text item delimiters of AppleScript to replace
        set subject to "" & subject
        set text item delimiters of AppleScript to prevTIDs
    
        return subject
    Last edited by Tito; 11 Jan 2017 at 04:34.

  3. #3
    MDL Novice
    Join Date
    22 Dec 2016
    Posts
    3
    Thanks Information

    Default

    Thanks to Tito for setting the code up in a spoiler box.

    I won't be able to get back to this to finish it until near the 27th of January, maybe over that weekend (so about 10 days from now).
    Any one who already knows how to finish this may feel free to do so!

    What I am seeking to have this script do is
    1. Start in a given folder.
    2. Check in that same folder and fix broken aliases.
    3. Check any subfolder of the starting folder, and fix any broken aliases in those folders also.

    In my case, I never have a duplicate (or so few I am not concerned) outside of the starting folder.

    for example:

    -Vacation 2016
    ----- at the beach
    ----- hang gliding
    ----- horseback riding

    -Vacation 2015
    . . . and so on

    Thanks,
    Kerry

Similar Threads

  1. Cant post in the correct sections?
    By Digital Void in forum Suggestions and Feedback
    Replies: 0
    Last Post: 17 Nov 2012, 08:31
  2. [SOLVED] [VB] Pointing to user folder
    By QuantumBug in forum Mixed Languages
    Replies: 5
    Last Post: 14 Sep 2012, 01:38
  3. Do you think this schedule is correct?
    By Samlappy in forum Windows 8
    Replies: 3
    Last Post: 29 Jun 2011, 02:44
  4. Correct or Not
    By ej52 in forum BIOS Mods
    Replies: 1
    Last Post: 18 Jun 2010, 17:55
  5. How can i check if my mod is correct?
    By EgonEis in forum Windows 7
    Replies: 0
    Last Post: 31 Jul 2009, 18:35

Tags for this Thread

Posting Permissions

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