找回密码
 加入
搜索
查看: 2398|回复: 5

[AU3基础] [已解决]选择多个文件如何显示文件路径的问题

[复制链接]
发表于 2010-11-22 21:27:48 | 显示全部楼层 |阅读模式
本帖最后由 xlcwxl 于 2010-11-26 20:32 编辑
FileOpenDialog多选出来的效果:

D:\downloads\2010
DSC00302.JPG
DSC01008.JPG
DSC01039.JPG

有时候选择的文件是快捷方式又会是这样的结果:

C:\Documents and Settings\Administrator\桌面
C:\Program Files\Tencent\QQ\Bin\QQ.exe
test3.au3
test.au3

我想要的效果:

D:\downloads\2010\DSC00302.JPG
D:\downloads\2010DSC01008.JPG
D:\downloads\2010DSC01039.JPG

C:\Documents and Settings\Administrator\桌面\test3.au3
C:\Documents and Settings\Administrator\桌面\test3.au3
C:\Program Files\Tencent\QQ\Bin\QQ.exe\test.au3
谢谢!

评分

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

查看全部评分

发表于 2010-11-25 11:45:42 | 显示全部楼层
貌似简单的用字符串相连处理一下就可以了啊!
如:$a=c:\windows
      $b=setup.exe
那么:
    $c=$a&'\'&$b
发表于 2010-11-26 09:17:00 | 显示全部楼层
方法一
#include <File.au3>
$a = 2
$filename = _TempFile(@TempDir, "~test", ".txt", 5)
$file = FileOpenDialog("test", @ScriptDir, "所有文件(*.*)", 7)
Local $temp = ""
If Not @error Then
        $file = StringRegExpReplace($file, "\|", @CRLF)
        FileWrite($filename, $file)
        $fileopen = FileOpen($filename, 0)
        If Not @error Then
                While 1
                        If StringInStr(FileReadLine($fileopen, $a), "") Then
                                $temp &= FileReadLine($fileopen, $a) & @CRLF
                        Else
                                If FileReadLine($fileopen, $a) <> "" Then
                                        $temp &= FileReadLine($fileopen, 1) & "" & FileReadLine($fileopen, $a) & @CRLF
                                EndIf
                        EndIf
                        $a += 1
                        If @error = -1 Then ExitLoop
                WEnd
        EndIf
        MsgBox(0, 0, $temp)
        FileClose($fileopen)
        FileDelete($filename)
EndIf
方法2 (暂时没想到控制数组的方法)
#include <Array.au3>
Local $temp3[20][2]
$file=FileOpenDialog("test",@ScriptDir,"所有文件(*.*)",7)
If Not @error Then
        $file=StringRegExpReplace($file,"\|",@CRLF)
        $temp1=StringRegExp($file,"(?m)^([^\v\\]+)\v*$",3)
        $temp2=StringRegExp($file,".*\\.*",3)
        For $i=1 To UBound($temp2)-1
                $temp3[$i-1][1]=$temp2[$i]
        Next
        For $y=0 To UBound($temp1)-1
                $temp3[$y][0]=$temp2[0]&""&$temp1[$y]
        Next
endif
_ArrayDisplay($temp3)

评分

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

查看全部评分

 楼主| 发表于 2010-11-26 20:27:14 | 显示全部楼层
回复 3# shenrenba

我想到的是第一种方法:
读取行,检测每行是否包含:\(路径符号),若有则直接读取,若没有则在每行之前加上第一行的路径
 楼主| 发表于 2010-11-26 20:33:17 | 显示全部楼层
谢谢!
shenrenba=(神人吧)?
发表于 2010-11-27 08:53:52 | 显示全部楼层
回复 5# xlcwxl


    不是  原来和朋友玩传奇的时候起的用户名   整个网吧玩的名字都是shenren 开头 方便大家记忆(于网吧名字有关,当时我的就是shenrenba)用习惯了 所以我大部分账号都是shenrenba
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-5-3 08:30 , Processed in 0.078959 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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