Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 813445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T01:21:38+00:00 2026-05-15T01:21:38+00:00

;Tool to archive files with specific extensions grouped by that extension and kept in

  • 0
;Tool to archive files with specific extensions grouped by that extension and kept in same file structure
;Will also keep original files in tact
;@Author - Scott Landau
;@Created - 5/23/2010
;@Last Edited - 5/23/2010

;Includes
#include <File.au3>
#include <Array.au3>
#include <Zip.au3>

;Globals
Local $tempExts="ade|adp|app|asa|ashx|asp|bas|bat|cdx|cer|chm|class|cmd|com|cpl|crt|csh|der|exe|fxp|gadget|hlp|hta|htr|htw|ida|idc|idq|ins|isp|its|jse|ksh|lnk|mad|maf|mag|mam|maq|mar|mas|mat|mau|mav|maw|mda|mdb|mde|mdt|mdw|mdz|msc|msh|msh1|msh1xml|msh2|msh2xml|mshxml|msi|msp|mst|ops|pcd|pif|prf|prg|printer|pst|reg|rem|scf|scr|sct|shb|shs|shtm|shtml|soap|stm|url|vb|vbe|vbs|ws|wsc|wsf|wsh"
Local $arrayExts = StringSplit($tempExts, "|")

;Methods
;Get the root directory for the archive
;@Return String
Func getRoot()
    Local $root = FileSelectFolder("Select Root:", "C:\")
    Return $root
EndFunc

;Gets all the subdirectories of the given directory
;@Param String
;@Return Array
Func getAllDirs($dir)
    Local $folderList = _FileListToArray($dir, "*", 2)
    Return $folderList
EndFunc

;Gets all the files of the given directory
;@Param String
;@Return Array
Func getAllFiles($dir)
    Local $fileList = _FileListToArray($dir, "*", 1)
    Return $fileList
EndFunc

;Get the file extension
;@Param String
;@Return String
Func getExt($file)
    Local $ext
    Local $pos = StringInStr($file, ".")
    $ext = StringTrimLeft($file, $pos)
    Return $ext
EndFunc

;Is bad extension?
;@Param String
;@Return Int
Func isBad($file)
    Local $retval
    Local $ext = getExt($file)
    Local $pos = _ArraySearch($arrayExts, $ext)
    If Not ($pos == -1) Then
        $retval = 1
    Else
        $retval = 0
    EndIf
    Return $retval
EndFunc

;Get all file extensions in current directory
;@Param String
;@Return Array
Func getAllExts($dir)
    Local $added = 0
    Local $allExts[1]
    Local $files = getAllFiles($dir)
    Local $max = UBound($files)
    For $i = 0 to $max - 1
        Local $ext = getExt($files[$i])
        If ($added == 0) Then
            $allExts[0] = $ext
            $added = 1
        Else
            _ArrayAdd($allExts, $ext)
        EndIf
    Next
EndFunc

;Actual archiving algorithm
;@Param String
Func algorithm($dir)
    Local $dirs = getAllDirs($dir)
    Local $files = getAllFiles($dir)
    Local $allExts = getAllExts($dir)

    Local $numExts = UBound($arrayExts)
    Local $numFiles = UBound($files)

    For $i = 0 to $numExts - 1
        Local $pos = _ArraySearch($allExts, $arrayExts[$i])
        If Not ($pos == -1) Then
            $zip = _Zip_Create(@WorkingDir & "\" & $arrayExts[$i] & "_zip.zip")
            For $j = 0 to $numFiles - 1
                Local $fileExt = getExt($files[$j])
                If ($fileExt == $arrayExts[$i]) Then
                    _Zip_AddFile($zip, $files[$j])
                EndIf
            Next
        EndIf
    Next

    Local $numDirs = UBound($dirs)
    For $k = 0 to $numDirs - 1
        algorithm($dirs[$k])
    Next

EndFunc

;Main archiving function to be run in 'Main' comment field
;Void
Func main()

    Local $root = getRoot()

    algorithm($root)

EndFunc

;Main
main()
  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T01:21:39+00:00Added an answer on May 15, 2026 at 1:21 am

    To find out what’s wrong, you need to either:

    • Add a progressbar and update it as the application runs through each function.
    • Use ConsoleWrite() to help you track what the application is doing as it runs when you are debugging in Scite.
    • Log your progress/success/errors to a log file that you can examine after you have run the application.

    I would recommend doing all the above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a tool that will automatically archivate old log files on
I installed http://weblogs.asp.net/scottgu/archive/2010/06/09/visual-studio-2010-productivity-power-tool-extensions.aspx but I can not find where I can make use of
I'm writing a Cocoa application that displays the contents of an archive file in
A tool (preferably free or open source) that converts java source code to html
I am working with the Code Metrics tool from Microsoft. http://blogs.msdn.com/b/camerons/archive/2011/01/28/code-metrics-from-the-command-line.aspx I have the
The requirenment is to the siverlight web UI will define the CSV file format
I have upgrade my MVC2 project to MVC3 using this tool: http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx Which is
According to the notes on office .dotm files, they are similar (or the same)
I currently have a directory with 98,000 individual archive transaction files. I need to
I have a PHP function below that is used for a command line tool

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.