2016-08-05 4 views
1

私はWindowsスクリプティングの初心者です。Windowsからのデータの検索と整理

複数のフォルダから「test」フォルダを探したいとします。複数のパスから

Searchテスト用フォルダのような:

/rbl.com/mailroot/test 
/pml.com/mailroot/test 
/pax.com/mailroot/ 

は、そのような出力を取得したい:

[email protected] 
[email protected] 

私は結果dir /S test > c:\results.txt

出力を取得するには、このコマンドを実行しています

Volume in drive C has no label. 
Volume Serial Number is 4A9E-06D4 

Directory of C:\Program Files (x86)\Parallels\Plesk\Mail Servers\Mail Enable\Postoffices\rbl.com\MAILROOT 

08/05/2016 12:36 AM <DIR>   test 
     0 File(s)    0 bytes 

Directory of C:\Program Files (x86)\Parallels\Plesk\Mail Servers\Mail Enable\Postoffices\pml.com\MAILROOT 

08/05/2016 12:36 AM <DIR>   test 
     0 File(s)    0 bytes 

しかし、どのような情報を抽出するには:

[email protected] 
[email protected] 
+0

あなたはどのバージョンのPowerShellを使用していますか( '$ PSVersionTable.PSVersion.Major'を参照)? –

答えて

0

これはトリックに

ls test -Directory -Recurse | % { "$($_.Name)@$($_.Parent.Parent.Name)" } 

を行う必要があり、それは親のフォルダの親をプリントアウトして、フォルダの当時、テスト・フォルダの再帰的に自分のフォルダを検索しますあなたが書式を設定したいと思う名前。

+0

その逆です。 '' {0} @ {1} "-f $ _。Name、$ _。Parent.Parent.Name' –

+0

コマンド' ls test -Directory -Recurse | **[email protected]** ** aoryxcarrental.ae @%( "$ _。Name)"}}このような出力は、テスト** – blaCkninJa

+0

これは私がこのような方法で同じコマンドを実行した 'ls test -Directory -Recurse | %{"$($ _。Name)@ $($ _。Parent.Parent.Name)"} – blaCkninJa

関連する問題