找回密码
 加入
搜索
查看: 3207|回复: 7

[AU3基础] (已解决)打开所有文件夹把文件夹下面的文件复制到桌面(具体见内容)

  [复制链接]
发表于 2010-11-26 17:43:37 | 显示全部楼层 |阅读模式
本帖最后由 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

评分

参与人数 1金钱 +10 收起 理由
afan + 10 感谢主动将修改帖子分类为[已解决],请继续 ...

查看全部评分

发表于 2010-11-26 18:07:38 | 显示全部楼层
论坛搜索 递归
发表于 2010-11-26 21:00:33 | 显示全部楼层
本帖最后由 netegg 于 2010-11-26 21:01 编辑
Func Search($current)
     Local $search = FileFindFirstFile($current & "\*.*")
     While 1
               Dim $file = FileFindNextFile($search)
               If @error Or StringLen($file) < 1 Then ExitLoop
               If StringInStr(FileGetAttrib($current & "" & $file), "D") And ($file <> "." Or $file <> "..") Then
                      shellexecute($current & "" & $file) 
                      Search($current & "" & $file)
               else
                      filecopy($current & "" & $file, @desktopdir  & "" & $file)
                 EndIf
     WEnd
Return
EndFunc ;==>Search

评分

参与人数 1金钱 +20 收起 理由
afan + 20

查看全部评分

 楼主| 发表于 2010-11-28 16:49:42 | 显示全部楼层
回复 3# netegg


   It works ! Thanks !

厉害!努力向你学习 原本以为自己能搞定 最后失去耐心了。。。
 楼主| 发表于 2010-11-28 18:24:59 | 显示全部楼层
回复 3# netegg


    And ($file <> "." Or $file <> "..")
是是吗作用?文件夹非空?
发表于 2010-11-28 18:48:51 | 显示全部楼层
不错,好好学习下。谢谢楼主分享!
发表于 2010-11-29 01:31:29 | 显示全部楼层
本帖最后由 netegg 于 2010-11-29 01:34 编辑

回复 5# yarsye

有时候会出这么个类似根目录的玩意,我也不清楚干什么用的,反正是想复制也复制不出去,只好排除了,就好象ftp里的 . 和 ..
 楼主| 发表于 2010-11-29 08:49:36 | 显示全部楼层
回复 7# netegg


    奥明白了 想的真是周全啊 别说还真的有用 像装了SVN后 每个文件夹下都隐藏了这种文件
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-10-2 22:25 , Processed in 0.075696 second(s), 22 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表