Created
December 15, 2015 12:05
-
-
Save AndrewHazelden/a7b6551915a71a44770e to your computer and use it in GitHub Desktop.
A LUA script for Blackmagic Design Fusion that will both check the current platform, and provide a file system related "dirname" function to trim a file path down to the base directory.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Find out the current operating system platform. The platform local variable should be set to either "Windows", "Mac", or "Linux". | |
local platform = "" | |
if string.find(fusion:MapPath("Fusion:\\"), "Program Files", 1) then | |
-- Check if the OS is Windows by searching for the Program Files folder | |
platform = "Windows" | |
elseif string.find(fusion:MapPath("Fusion:\\"), "PROGRA~1", 1) then | |
-- Check if the OS is Windows by searching for the Program Files folder | |
platform = "Windows" | |
elseif string.find(fusion:MapPath("Fusion:\\"), "Applications", 1) then | |
-- Check if the OS is Mac by searching for the Applications folder | |
platform = "Mac" | |
else | |
platform = "Linux" | |
end | |
-- Find out the current directory from a file path | |
-- Example: print(dirname("/Users/Shared/file.txt")) | |
function dirname(mediaFileName) | |
-- LUA dirname command inspired by Stackoverflow code example: | |
-- http://stackoverflow.com/questions/9102126/lua-return-directory-path-from-path | |
sep = '' | |
if platform == "Windows" then | |
sep = "\\" | |
elseif platform == "Mac" then | |
sep = "/" | |
else | |
-- Linux | |
sep = "/" | |
end | |
return mediaFileName:match("(.*"..sep..")") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment