args P, T, M local Result, i, BegP, BegT local Bef = "" if(P == T) do Result = Bef ++ M ++ Aft clip.set(Result) quit endif local SourceDepth = runfile.Subs\Sub_ParsePath(P, "") local TargetDepth = runfile.Subs\Sub_ParsePath(T, "") if(index(P, T) != 0) do Result = Bef ++ repeat("../", SourceDepth - TargetDepth) ++ M ++ Aft clip.set(Result) quit endif if(index(T, P) != 0) do Result = Bef ++ select(T, length(P) - length(T)) ++ M ++ Aft clip.set(Result) quit endif local Lim = min(SourceDepth, TargetDepth) local Counter = 0 for(i = 1; i <= Lim; i = i + 1) Result = BegP BegP = runfile.Subs\Sub_ParsePath(P, i - SourceDepth) BegT = runfile.Subs\Sub_ParsePath(T, i - TargetDepth) if(BegP == "" || BegT == "") break if(BegP == BegT) do Counter = Counter + 1 else break endif endfor if(Counter == 0) do local mpDlgCaption = "LinkPath Script" local mpIcon = "WARNING" local mpDlgText = "Source path is " ++ P ++ "\nTarget file is " ++ T ++ M mpDlgText = mpDlgText ++ "\nThey seem to be on different logical disks!" miscplugin.messagebox(1, "&OK") quit endif Result = repeat("../", SourceDepth - Counter) Result = Result ++ runfile.Subs\Sub_ParsePath(T, TargetDepth - Counter) ++ "/" Result = Bef ++ replacechars(Result, "\", "/") ++ M ++ Aft clip.set(Result)