Events for local file manipulation?
Posted: Sat Apr 09, 2016 12:04 pm
Hi, it is possible create event if file is uploaded to folder localy?
Thank you
Thank you
The official forum of Wing FTP Software
https://bbs.wftpserver.com/
Code: Select all
local movies = "D:/Movies/"
local emailSubject = "New files"
local emailBody = ""
local emailSMTP = "MySMTP"
function difference(a, b)
local aa = {}
for k,v in pairs(a) do aa[v]=true end
for k,v in pairs(b) do aa[v]=nil end
local ret = ""
local n = 0
for k,v in pairs(a) do
if aa[v] then
v = string.gsub(v,movies,"")
n=n+1
ret = ret..v.."\n"
end
end
return ret
end
function FileWalker(options)
local oldlist = {}
local newlist = ""
local path = options.path
local fileTable = {}
for line in io.lines(options.old) do
table.insert(oldlist, line)
end
function walk(path)
for isdir, file in c_GetFileDir(path) do
if isdir == true then
fullPath = path..file.."/"
walk(fullPath)
else
fullPath = path..file
table.insert(fileTable, fullPath)
newlist = newlist..fullPath.."\n"
end
end
end
walk(path)
local file = io.open(options.old, "w")
file:write(newlist)
file:close()
return difference(fileTable,oldlist)
end
local updates = FileWalker{path=movies, old="D:/movies.txt"}
if updates ~= "" then
emailBody = emailBody.."New movies on FTP: \n\n"..updates.."\n\n"
end
if emailBody ~= "" then
c_SendMail("your@domain.com",emailSubject,emailBody,"",emailSMTP)
end