Board logo

标题: [求助]搜索指定目录名称为数字的文件夹,并列出来。 [打印本页]

作者: zmt1982     时间: 2007-5-25 15:50    标题: [求助]搜索指定目录名称为数字的文件夹,并列出来。

提2个问题,希望高手解答,谢谢:

1. 搜索指定目录内名称为数字的文件夹。并列出来,这个批处理怎么写?(只要名称,不要路径)

2.搜索指定的文件名,并把这个文件名所有所在的文件夹名列出来。只要文件夹名称,全不要路径。

谢谢。

告诉大家我的作用吧,我这么做其实是想搜索QQ目录内的数字文件夹,然后列出这台电脑有那些QQ上过。

[ Last edited by zmt1982 on 2007-5-25 at 03:52 PM ]
作者: lxmxn     时间: 2007-5-25 16:39
1
CODE:  [Copy to clipboard]
dir /ad/b "%programfiles%\tencent\qq"|findstr /r /c:"^[0-9]*$"
第2个问题,搜索指定的文件名,在哪里搜索?指定的路径下么?
作者: wudixin96     时间: 2007-5-25 16:40
CODE:  [Copy to clipboard]
dir /ad /b|findstr "^[0-9]*$"
类似这样

没见到版主已经回了。当灌水了。呵呵

[ Last edited by wudixin96 on 2007-5-25 at 04:44 PM ]
作者: zhoushijay     时间: 2007-5-25 16:40
VBS版 以前的代码稍微改了下
CODE:  [Copy to clipboard]
dim fso,finm,all
set ws=wscript.createobject("wscript.shell")
set fso=createobject("scripting.filesystemobject")

QQpath=ws.regread ("HKEY_LOCAL_MACHINE\SOFTWARE\Tencent\QQ\Install")
set flnm=fso.getfolder(QQpath)
set all=flnm.subfolders


for each path in all
    dim fs,fnm
    set fs=createobject("scripting.filesystemobject")
    fnm=fs.getfilename(path)

    on error resume next
    fnm=int(fnm)
    if err.number<>13 then
       dim list
       list=list&fnm&chr(10)
    end if
next
msgbox "已登陆过的QQ号码:"&chr(10)&list,vbinformation,"清除QQ账号存留文件"

作者: slore     时间: 2007-5-25 16:56
这个是你的代码:
Dim fso,finm,all
Set ws = wscript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

QQpath = ws.regread ("HKEY_LOCAL_MACHINE\SOFTWARE\Tencent\QQ\Install")
Set flnm = fso.getfolder(QQpath)
Set all = flnm.subfolders


For Each path In all
    Dim fs,fnm
    Set fs = CreateObject("Scripting.FileSystemObject")
    fnm = fs.getfilename(path)

    on Error Resume Next
    fnm = Int(fnm)
    If Err.Number <> 13 Then
        Dim list
        list = list & fnm & Chr(10)
    End If
Next
MsgBox "已登陆过的QQ号码:" & Chr(10) & list,vbinformation,"清除QQ账号存留文件"


看看"稍微"修改的结果:
Dim fso,finm,all
Set ws = wscript.CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

QQpath = ws.regread ("HKEY_LOCAL_MACHINE\SOFTWARE\Tencent\QQ\Install")
Set flnm = fso.getfolder(QQpath)
Set all = flnm.subfolders


For Each path In all
    Dim fnm,list
    fnm = path.name
    'set fs=createobject("Scripting.FileSystemObject")
    'fnm=fs.getfilename(path)
    'on error resume next
    If IsNumeric(fnm) Then  list = list & fnm & vbLf
    'end if
Next
MsgBox "已登陆过的QQ号码:" & vbLf & list,vbinformation,"清除QQ账号存留文件"

Set all = Nothing
Set flnm = Nothing
Set fso = Nothing
Set ws = Nothing

你的For Each path In all太臃肿了......
作者: zhoushijay     时间: 2007-5-25 17:19
IsNumeric  哈哈,又学到一个,谢谢




欢迎光临 中国DOS联盟论坛 (http://cndos.fam.cx/forum/) Powered by Discuz! 2.5