;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()
-2
A
回答
0
要找出什麼是錯的,你需要:
- 添加進度和應用程序運行時通過每個功能更新。
- 使用ConsoleWrite()可幫助您跟蹤在Scite中調試時應用程序正在執行的操作。
- 將您的進度/成功/錯誤記錄到您可以在運行應用程序後檢查的日誌文件中。
我會建議做所有上述。
相關問題
- 1. AutoIt腳本運行.exe文件
- 2. 從Excel VBA運行Autoit腳本
- 3. AutoIt腳本來運行exe文件
- 4. AutoIT腳本創建並運行
- 5. autoit腳本不工作
- 6. 從命令行執行AutoIt腳本
- 7. Autoit腳本沒有在Java運行時執行
- 8. AutoIT腳本的運行不一致。爲什麼它會自行暫停?
- 9. 如何安排每天運行AutoIt腳本?
- 10. 我可以在後臺運行Autoit腳本來上傳文件
- 11. 腳本不運行
- 12. AutoIT運行記事本命令
- 13. PHP腳本不會運行
- 14. PHP腳本不會運行
- 15. Python腳本不運行
- 16. ASP腳本將不運行
- 17. 腳本不一致運行
- 18. 運行不同liquibase腳本
- 19. 腳本的運行腳本
- 20. 在Eclipse中爲AutoIt腳本獲取文件的運行時間路徑
- 21. 在Laravel中運行python腳本,腳本運行但不完全執行?
- 22. Qpython - 運行腳本時不可執行
- 23. 如何在Python中調用AutoIt腳本
- 24. AutoIT腳本/ UDF與Amazon S3 API接口
- 25. 運行shell腳本
- 26. 運行shell腳本++
- 27. VRML運行腳本
- 28. 運行Python腳本
- 29. 運行shell腳本
- 30. 運行Perl腳本
你需要提供更多的細節,你應該更新你的原始問題(http://stackoverflow.com/questions/2867689/autoit-scripts-runs-without-error-but-i-cant-see-archive-更新)而不是創建一個新的。 – aphoria 2010-05-25 01:29:48