Page 1 of 1

Automatic decompress uploaded zip files

PostPosted: Sun Jan 03, 2010 2:22 pm
by FTP
-- Description: Automatic decompress uploaded zip files
-- You should add the below scripts to the event manager -> FTP or HTTP OnFileUploaded
-- And I suppose you have installed WinRAR in the directory "C:\Program Files\WinRAR"
-- Author: Luke
-- Date: 2010-01-01

Code: Select all
local fname = string.gsub("%PathName", "\\","/")
local dpath = string.sub(fname,0,string.len(fname)-4)
local ext = string.lower(string.sub(fname,-4))

if ext == ".rar" or ext == ".zip" or ext == ".tgz" then

os.execute("C:\\Progra~1\\WinRAR\\WinRAR x -Y \""..fname.."\" \""..dpath.."\\\" ")

end


Image

Re: Automatic decompress uploaded zip files

PostPosted: Tue Mar 23, 2010 3:45 pm
by duke2315
This Script work great. The only question i have is if you can set this script to extract the files in the Archive to the root directory instead of creating another folder within the root directory.

Re: Automatic decompress uploaded zip files

PostPosted: Wed Mar 24, 2010 11:29 am
by FTP
OK, you can make it, just replace the line:

local dpath = string.sub(fname,0,string.len(fname)-4)

into this:

local dpath = string.sub(fname,0,string.len(fname)-string.find(string.reverse(fname),"/"))



BTW, you may write lua script by yourself, it is not very hard.