Automatic decompress uploaded zip files

You can share your Lua Scripts with everybody here.

Automatic decompress uploaded zip files

Postby FTP » Sun Jan 03, 2010 2:22 pm

-- 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
FTP
Site Admin
 
posts 1202
 
joined Tue Sep 29, 2009 6:09 am

Re: Automatic decompress uploaded zip files

Postby duke2315 » Tue Mar 23, 2010 3:45 pm

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.
duke2315
 
posts 1
 
joined Tue Mar 23, 2010 3:10 pm

Re: Automatic decompress uploaded zip files

Postby FTP » Wed Mar 24, 2010 11:29 am

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.
FTP
Site Admin
 
posts 1202
 
joined Tue Sep 29, 2009 6:09 am


Return to Lua scripts

Who is online

Users browsing this forum: No registered users and 1 guest

cron