------------------------------------------------------ -- Change all loaders pointing to .lnk files to the -- target of the windows shortcut , Revision: 1.0 -- -- place in Fusion:/Scripts/Comp/AT -- -- Written by Matthew Irwin (mirwin[REMOVE-ME]@anatomicaltravel.com) -- Copyright (c) 2007 Anatomical Travelogue LLC -- (http://www.anatomicaltravel.com/research) -- The authors hereby grant permission to use, copy, and distribute this -- software and its documentation for any purpose, provided that existing -- copyright notices are retained in all copies and that this notice is -- included verbatim in any distributions. Additionally, the authors grant -- permission to modify this software and its documentation for any -- purpose, provided that such modifications are not distributed without -- the explicit consent of the authors and that existing copyright notices -- are retained in all copies. -- IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR -- DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING -- OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES -- THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF -- SUCH DAMAGE. -- THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, -- INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND -- DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, -- UPDATES, ENHANCEMENTS, OR MODIFICATIONS. ------------------------------------------------------ print("\n\n----------------------------------------------\nCONVERT SHORTCUT LOADERS:\n----------------------------------------------\n\n") composition:Lock() toollist = composition:GetToolList(false) FilenameList = {} ShortcutLoaderList = {} fNoShortcuts=true intShortcutCount=0 for i, tool in toollist do tool_a = tool:GetAttrs() if tool_a.TOOLS_RegID == "Loader" then if tool_a.TOOLST_Clip_Name[1] ~= nil then seq = eyeon.parseFilename(tool_a.TOOLST_Clip_Name[1]) if seq.Extension == ".lnk" then fNoShortcuts=false intShortcutCount=intShortcutCount+1 --print("SHORTCUT FILE: " .. tool_a.TOOLST_Clip_Name[1]) FilenameList[intShortcutCount] = tool_a.TOOLST_Clip_Name[1] ShortcutLoaderList[intShortcutCount]=tool end end end end if fNoShortcuts==true then print("Error: No .lnk files to process") else for i in FilenameList do fNetworkAddress=false --print(FilenameList[i]) literalPath=fusion:MapPath(FilenameList[i]) print("Filename list: ".. FilenameList[i]) print("Literal path: " ..literalPath) if fileexists(literalPath) then fh, errorMsg = io.open(literalPath, "rb") if fh == nil then -- failed to open the file. -- print an error and halt print("Error: Failed to open input file!") print(errorMsg) exit(20) end -- read all of the lines at once content = fh:read("*all") local validchars = "[%w%p%s]" local pattern = string.rep(validchars, 2) .. "+%z" for w in string.gfind(content, pattern) do if string.find(w,':\\')~=nil then curFile=string.format('%s',w) elseif fNetworkAddress==true then curFile = curFile .. "\\" .. string.format('%s',w) fNetworkAddress=false elseif string.find(w,'\\\\')~=nil then curFile=string.format('%s',w) fNetworkAddress=true end end fh:close() if MapPath(curFile) == nil then curFile=string.sub(curFile,1,-2) end literalCurFile=fusion:MapPath(curFile) curLD = ShortcutLoaderList[i] tool_a=curLD:GetAttrs() startTime = tool_a.TOOLNT_Clip_Start print("SHORTCUT FILE: " .. tool_a.TOOLST_Clip_Name[1]) if fileexists(literalCurFile) then print("TARGET FILE: ".. literalCurFile) ShortcutLoaderList[i].Clip=literalCurFile else print( "FAILED : Clip does not exist; skipping sequence.\n " .. literalCurFile) end print("-----") else print( "FAILED : Shortcut file does not exist; skipping sequence.\n " .. FilenameList[i]) end end end composition:Unlock()