2017-01-22 2 views
0

現在のディレクトリのすべてのサブフォルダでvbscriptを実行しようとしています。 これまでのところ:すべてのサブフォルダで別のvbscriptを実行するためにvbscriptを使用していますか?

CreateObject("Wscript.Shell").Run("""*\dirlistnew.vbs""") 

しかし、それは動作しません。私が*\を削除すると、現在のディレクトリで動作しますが、サブディレクトリでは動作しません。私は何かが簡単でないことを知っている。検索して何時間も何も役に立たないものを試していた。

+1

検索 –

+0

うーん... *「検索し、無駄に時間の事をしようとして」*本当に、私は4分前に検索し、その重複を見つけました、あなたは何を検索しましたか? – Lankymart

答えて

0

スニペットの私のライブラリからこれを得ました。あなたのニーズに合わせて調整してください。 テストされていませんが、私は過去数年間、Rubyを使用しています。

'call our sub with the desired path as option 
' this needs to be a Folder object, not a String 
' FSO.GetFolder will return that object given a path as string 
ShowSubfolders FSO.GetFolder(path) 

Sub CreateHtml(path) 
    ' put here the code from your other script (best) 
    ' or do your call to execute the other script 
    ' you probably need the path so you pass it as a parameter 
End Sub 

Sub ShowSubFolders(Folder) 
' a Folder has the method SubFolders, 
' gives a collection of subfolders that can be enumerated 
' with For Each construct 
    For Each Subfolder in Folder.SubFolders 
    ' print the subfolder so you can follow the progress 
    Wscript.Echo Subfolder.Path 
    ' and call the sub that creates the html file 
    CreateHtml Subfolder.Path 
    ' here the magic of recursion, the sub is calling itself with 
    ' as parameter the subfolder to process the subsubfolders etc 
    ShowSubFolders Subfolder 
    Next 
End Sub 

それだけで1行だRubyでNB「VBScriptのサブフォルダを再帰サイト:stackoverflow.com」のDir["#{folder}/*"].each{|f| puts f if File.directory?(f) }

+0

あなたがこのような質問に答えることに決めたとき、あなたはそれらの多くを励まします。問題は最高の状態ではなく、問題に自分自身で近づこうとする試みはほとんど、あるいはまったくありません。 – Lankymart

+0

はい、あなたはそれのような離れた新しいユーザーを恐れますが、それは二重ではありませんでしたが、 – peter

+0

NB:彼らはRubyではなくVBScriptソリューションを求めています。 – Lankymart

関連する問題