本帖最后由 yarsye 于 2010-11-28 16:54 编辑
目的:判断当前脚本下是否有文件夹 ,如果有则打开,直到最后一个文件夹为空 ,然后再一个个关掉。
例如:当前脚本下有5个文件夹同时存在,文件夹1,2,3,4,5, 每个文件夹下又个5个文件夹,这样总共有3到4层。
我把自己给绕晕了,先使用filegetarrtib判断当前脚本下是'D'还是'A‘ ,'D'代表目录也就是文件夹,'A'代表单独文件,如果是D 那么就进入这个文件夹,如果是A就把文件复制到桌面上。
基本上3层下面的5个文件夹下面都应该对应文件,判断是3层还是4层,然后进去找到文件,复制到桌面。
说起来好像挺简单的 ,被那个循环给弄晕了。
大侠有空或者有兴趣可以帮忙研究下 , 谢谢了。#include <File.au3>
#include <Array.au3>
Opt("MustDeclareVars",0)
Local $path, $h, $FileList3
$path = @ScriptDir & "\apk"
$FileList = _FileListToArray($path)
If @error = 1 Then
MsgBox(0,"","No Files\Folders Found.",5)
Exit
EndIf
If $FileList[0] = 0 Then
MsgBox(0,"Sorry","There is no file in the folder",5)
Exit
EndIf
;~ _ArrayDisplay($FileList ,"first list")
;=============================================
For $a = 1 To $FileList[0]
$FileListA = _FileListToArray($path & $FileList[$a] & "")
If @error = 1 Then
MsgBox(0,"","No Files\Folders Found.",5)
Exit
EndIf
If $FileListA[0] = 0 Then
MsgBox(0,"Sorry","There is no file in the folder",5)
Exit
EndIf
For $b =1 To $FileListA[0]
$FileListB = _FileListToArray(0,111,$path & $FileList[$a] & "" & $FileListA[$b] & "")
;~ If @error = 1 Then
;~ MsgBox(0,"o","No Files\Folders Found.",5)
;~ Exit
;~ EndIf
;~ If $FileListB[0] = 0 Then
;~ MsgBox(0,"Sorry","There is no file in the folder",5)
;~ Exit
;~ EndIf
ShellExecute($path & $FileList[$a] & "" & $FileListA[$b] & "" )
Sleep(1000)
Send("{Down}{Up}{Enter}")
Sleep(2000)
Send("!{F4}")
Sleep(1000)
Next
Next
;=============================================
#cs
For $i = 1 To $FileList[0]
If StringInStr(FileGetAttrib($path & $FileList[$i]), 'A') Then
MsgBox(0, $i, $FileList[$i], 1);out
EndIf
If StringInStr(FileGetAttrib($path & $FileList[$i]), 'D') Then
;===================================================================================
$path1 = $path & $FileList[$i] & ""
$FileList1 = _FileListToArray($path1)
If $FileList1[0] = 0 Then
Exit
EndIf
For $j = 1 To $FileList1[0]
If StringInStr(FileGetAttrib($path1 & $FileList1[$j]), 'A') Then
MsgBox(0, $j, $FileList1[$j], 1);out
EndIf
If StringInStr(FileGetAttrib($path1 & $FileList1[$j]), 'D') Then
;===================================================================================
$path2 = $path1 & $FileList1[$j] & ""
$FileList2 = _FileListToArray($path2)
If $FileList2[0] = 0 Then
Exit
EndIf
For $k = 1 To $FileList2[0]
If StringInStr(FileGetAttrib($path2 & $FileList2[$k]), 'A') Then
MsgBox(0, $k, $FileList2[$k], 1);out
;~ MsgBox(0,111,$path2)
EndIf
;~ If StringInStr(FileGetAttrib($path2 & $FileList2[$k]), 'D') Then
;~ ;===================================================================================
;~ $path3 = $path1 & $FileList1[$j] & "" & $FileList2[$h] & ""
;~ $FileLista = _FileListToArray($path3)
;~ If $FileLista[0] = 0 Then
;~ Exit
;~ EndIf
;~ For $h = 1 To $FileLista[0]
;~ If StringInStr(FileGetAttrib($path3 & $FileLista[$h]), 'A') Then
;~ MsgBox(0, $h, $FileLista[$h], 1);out
;~ EndIf
;~ If StringInStr(FileGetAttrib($path3 & $FileLista[$h]), 'D') Then
;~ EndIf
;~ Next
;~ EndIf
Next
EndIf
Next
EndIf
Next
EndFunc ;==>FindFolder
;~ Global $result
;~ digui(5)
;~ MsgBox(0,1,$result)
;~ Func digui($k)
;~ If $k = 1 Then
;~ $result = $k * 1
;~ Else
;~ $result = $k * ( digui($k-1))
;~ EndIf
;~ Return $result
;~
#ce
|