[JW Lua] Perform operations on folder files
Chris
marcel.denio at gmail.com
Mon Dec 21 15:02:14 CET 2015
Hello Jari and all
Is this the right method to perform operations on folder files ?
(LoadFolderFiles and ForEachFile have no filter)
-----------------------------------------
local function getExtension(filename)
local extension = finale.FCString()
extension:SetString(filename)
extension:ExtractFileExtension()
return extension
end
local function isFinaleExtension(extension)
local FINALEEXTENSIONS = {"musx","MUSX","mus","MUS"}
for _ , v in ipairs(FINALEEXTENSIONS) do
if extension:IsEqual(v) then return true end
end
return false
end
local function myfilecallback(doc, filename)
if not doc then return end
-- ******* OPERATIONS *********
print(filename.LuaString)
end
local dialogFolder = finale.FCFolderBrowseDialog(finenv.UI())
if dialogFolder:Execute() then
local folderPath = finale.FCString()
dialogFolder:GetFolderPath(folderPath)
folderPath:AssureEndingPathDelimiter()
local filenames = finale.FCStrings()
filenames:LoadFolderFiles(folderPath)
for filename in each(filenames) do
local extension = getExtension(filename)
if isFinaleExtension(extension) then
filename:InsertString(folderPath,0)
else
filename:Clear()
end
end
filenames:ClearEmptyStrings()
local iterator = finale.FCLuaIterator()
iterator:ForEachFile(filenames, myfilecallback)
end
-----------------------------------------
Best regards
Chris
More information about the JWLua
mailing list