代码之家  ›  专栏  ›  技术社区  ›  Scott

autoit脚本未运行

  •  -2
  • Scott  · 技术社区  · 16 年前
    ;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 回复  |  直到 16 年前
        1
  •  0
  •   JohnForDummies    16 年前

    要找出问题所在,您需要:

    • 添加一个进度条,并在应用程序运行每个函数时对其进行更新。
    • 使用consolewrite()帮助您跟踪应用程序在Scite中调试时的运行情况。
    • 将您的进度/成功/错误记录到日志文件中,您可以在运行应用程序后检查该文件。

    我建议你这么做。