Zip file collection of a folder by selected file extension
An easy way to archive files for backup or to send to others, etc.
Required: free zip component from http://www.xstandard.com/page.asp?p=C9891D8A-5390-44ED-BC60-2267ED6763A7 - if your host's server doesn't have this installed, ask their tech support to install it for you.
I can think of lots of ways one could write scripts for this component. For example one could use the script below as the basis for a set of scripts whereby one would put all the filenames and dates-modified into a database and then would be able to scan a folder and compare the files in the folder to the names and dates of those in the database...then add any new files to the zip archive and update files of the same names that have been updated recently.
See also, another zip script using this component.
| <% 'zip_by_file_extension.asp 'zip multiple files using file collection 'script by Lil Peck, equineexpo.com/aspexamples 'Required: free zip component from http://www.xstandard.com/page.asp?p=C9891D8A-5390-44ED-BC60-2267ED6763A7 dim Ftype Ftype = ".htm" ' choose the file extension you want to put into the zip folder dim myName myName = "MyFileArchive.zip" 'whatever you want your zip filename to be 'to name your file dynamically by the current date and time you can use "M" & Month(now())&"_"& "D" & Day(now())&"_"&"Y" & Year(now())&"_"& "m" & Minute(now())&"_"&"S" & Second(now())& ".zip" Dim objZip Set objZip = Server.CreateObject("XStandard.Zip") Dim objFileScripting, objFolder Dim filename, filecollection, strDirectoryPath, strUrlPath 'strDirectoryPath="D:\yourpath\public_html\backup\test" ' change to the folder you want zip to go to 'get file scripting object Set objFileScripting = CreateObject("Scripting.FileSystemObject") 'Return folder object Set objFolder = objFileScripting.GetFolder("D:\yourpath\public_html\backup\myfolder\") 'change to your folder with the files to zip 'return file collection In folder Set filecollection = objFolder.Files 'place each file into the zip file For Each filename In filecollection objZip.Pack "D:\yourpath\public_html\backup\myfolder\*" & Ftype,"D:\yourpath\public_html\backup\test\" & myName response.write " ...reading file names... " & filename & " <br>" Next response.write "<br><br><b>Here's your file: " & "http://yoursiteurl/backup/test/" & myName & "<b>" 'change url to your folder Set objZip = Nothing %> |