osx - how to fix 100's of alias' on mac after migration? -


i hope can me out this. moved 1 mac , did clean install. have several folders hundreds of alias (how plural of alias?)...

the original file path "/volumes/media drive/ableton/warped tracks/", , new path needs "/users/joel/music/ableton projects/warped tracks"

i see how fix them 1 @ time, take hours. tried applescript, had no luck: https://apple.stackexchange.com/questions/2656/how-do-i-fix-failed-aliases

can give me better applescript or solution? mentioned, tried applescript:

tell application "finder"     set these_items selection end tell  repeat 1 count of these_items     set this_item (item of these_items) alias     set this_info info this_item      if class of this_item alias         tell application "finder"             set original_file original item of this_item             set this_alias_file_name displayed name of this_item             set container_folder container of this_item              set the_path posix path of (original_file alias)             set new_path replacetext("/volumes/media drive/ableton/warped tracks/", "/users/joel/music/ableton projects/warped tracks", the_path)              move this_item trash             try                 make new alias file @ container_folder (posix file new_path) properties {name:this_alias_file_name}             on error errmsg number errornumber                 if errornumber -10000 -- new original file not found, try relinking old                     try                         make new alias file @ container_folder (posix file the_path) properties {name:this_alias_file_name}                     on error errmsg number errornumber                         if errornumber -10000 -- old original not found. link's dead jim                             display dialog "the original file alias " & this_alias_file_name & " not found."                         else                             display dialog "an unknown error occurred:  " & errornumber text                         end if                     end try                 else                     display dialog "an unknown error occurred:  " & errornumber text                 end if             end try         end tell     end if end repeat  on replacetext(find, replace, subject)     set prevtids text item delimiters of applescript     set text item delimiters of applescript find     set subject text items of subject      set text item delimiters of applescript replace     set subject "" & subject     set text item delimiters of applescript prevtids      return subject end replacetext 

any appreciated.

edit: think problem applescript me have folders further down path different, , each contain individual alias files. ie: "/users/joel/music/ableton projects/warped tracks/folder a/file.alias",/users/joel/music/ableton projects/warped tracks/folder b/file2.alias", etc, etc

i had same issue years ago (transfer between 2 media centers), , made program : asks folder broken alias , try find again original path rebuild them.

the thing applescript instruction alias gives error when link broken, must use finder info window read original path without error when link broken: (this program assumes original file name unique)

-- select main folder tell application "finder" set mon_dossier ((choose folder prompt "select top folder:" without invisibles) alias) string  -- repair alias in folder , subsequent folders (entire contents) tell application "finder" set mes_alias every file of entire contents of folder mon_dossier class alias file -- loop on each alias of folder repeat mon_alias in mes_alias     -- found original file path of mon_alias     -- try first standard alias call        set f_source ""     try         tell application "finder" set f_source original item of mon_alias     end try     if f_source ""         -- link original file broken, use on windows info method         set f_source origine_alias(mon_alias)         set f_original decompose(f_source)         -- no need original file is, becuase link broken (path changed ?)         -- directly search same file without extension         set cible ((chemin of f_original) string) & ((nom of f_original) string)         tell application "finder"             if exists file cible                 -- file found without extension                 -- delete alias , create new alias same name , in same folder                 set a_nom name of mon_alias                 set a_dossier folder of mon_alias                 delete mon_alias                 set nouvel_alias make alias cible @ a_dossier                 set name of nouvel_alias a_nom             else                 slog("alias=" & (mon_alias string) & "       file not found=" & cible)             end if         end tell     else         -- alias link still valid : nothing ! go next alias..     end if end repeat -- end main program   -- sub routine find passe of broken link (original path/file can't found) -- result unix path folder/sub_folder/file on origine_alias(f_alias)     set r ""     tell application "finder" open information window of file (f_alias text)     tell application "system events" tell process "finder" set r value of static text 19 of scroll area 1 of front window     tell application "finder" close front window     return r end origine_alias   -- sub routine extract, unix file path, path, file name , extension: result sent in record -- warning : can't use "posix file of" becuase path , file non longer valid ! (then posix gives error) on decompose(local_f)     --search first "." right find extension     set x length of local_f     repeat while (character x of local_f not ".") , (x > 0)         set x x - 1     end repeat     if x > 0         set l_ext text (x + 1) thru (length of local_f) of local_f         set local_f text 1 thru (x - 1) of local_f     else         l_ext = "" -- "." not found, no extension !     end if     -- search first "/" right extract file name     set x length of local_f     repeat while (character x of local_f not "/")         set x x - 1     end repeat     set l_nom text (x + 1) thru (length of local_f) of local_f     set local_f text 1 thru (x) of local_f     try         set l_chemin posix file local_f     end try     return {chemin:l_chemin, nom:l_nom, ext:l_ext}  end decompose  -- sub routine log (text log file on desktop) on slog(msg)     set my_log ¬         ((path desktop) text) & "my_logfile.txt"     try         -- open file. create if not yet exist         open access file my_log write permission         -- add text @ end of file         write (msg & return) file my_log starting @ eof         close access file my_log     on error         try             close access file my_log         end try     end try end slog 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -