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
%>


 

ASP Examples Menu of Active Server Pages scripts code Classic ASP

Classic ASP Active Server Pages Examples, code, tutorials, scriptsASP Examples Menu (below*)



Active Server Pages | ASP | Scripts | Tutorials | Code | Web Programming | Examples
Active Server Pages ASP code examples, tutorials, and snippets for use in Programming interactive websites.

NOTE: Recently changed hosting and url so some demos aren't working now because I haven't updated pathing; if you find omissions or errors let me know.
 

*

Multiple records per row with paging

Display multiple records per row

Get ID of newly inserted record, Classic ASP, Access Database

Javascript timer with ASP to keep track of time expired until login expires / timeout session is up

Multiple Javascript event functions triggered from single form onsubmit

Get Querystring key names along with querystring variables

ASP Youtube Downloader  Version FOUR
All ASP code. Allows user client side downloads of Youtube videos. You have the option to allow files to be saved directly to your site also.

ASP/PHP video downloader (Works better than ASP for large files)

Use ASP to dynamically parse a Youtube XML playlist to render to html.

Zip up an archive file of your site for backup if you need to restore website with ASP and free Zip Component.

Zip all files in a folder into an archive or backup file dynamically by specific file extension.

Sanitize or clean price cost field for database insertion or display.

Javascript image dimensions and image file size preview.

Put recordset into array, assign keys to the records then use record associated with specific array key as a variable elsewhere.

Access Database Interface Generator Wizard to read your table and field names and to create a table display.

Combining dropdown selection box menu with dynamic ASP database page.

How to redirect user to original page they tried to view before logging, after they are logged in.

Previous/Current/Next Records, or Buddy Ring Script

Custom ASP 404 page not found error script sends visitors to virtual folders

ASP Example: Combine ASP with Javascript for popup windows
dynamically sized to image dimensions.

ASP Example: How to use ASPJPEG to create thumbnails
Click for free Highly recommended thumbnailer for which you don't need Server access

ASPjpeg: How to re-scale aspect ratio of thumbnails by height instead of width.

ASP Example: What if your host has an older version of ASPJPEG that doesn't support gifs?

Using inline frames as "dynamic includes" (offline for updating)

Select Count Distinct Records for Access Database

Upload Image to folder and insert filename into database

Get date in such a way that it can be made part of a file name

Isolate a file name away from its path or extension or strip a path from a file name or strip characters from database field

User-customized on-the-fly stylesheet css files

Enhanced Page Hits Counter (also counts downloads and menu link hits)

Loop through array and compare to string with select case

Aphabetical Paging for your ASP scripts

Web Wiz Guide's Site Searcher Script modified as a file content indexer

Let Users Select How Many Records to View

Access Database for your PayPal IPN scripts

Miscellaneous collected code

You don't have to be a genius, just persistent, to write original Active Server Pages scripts

Software Recommendation: bare_bones_no_bells_and_whistles_asp_code_generator_database_interface_maker

--Lil at gmail.com