ディレクトリが存在しない場合は、いくつかのターゲット場所にディレクトリを作成しようとしています。Powershellでディレクトリを作成しようとしています
ディレクトリの名前は別のソース場所からのものです。 C:\some\location
内の各ディレクトリ名の
は、例えばC:\another\location.
に同じ名前の新しいディレクトリを作成します。
c:\some\location\
\apples
\oranges
to
c:\another\location\
\apples
\oranges
source -> to -> target
からすべてのフォルダを再作成しています。 再帰的ではありません。ちょうどトップレベル。
だから私はPSで、これまでこれを持っている:
dir -Directory | New-Item -ItemType Directory -Path (Join-Path "C:\jussy-test\" Select-Object Name)
または
dir -Directory | New-Item -ItemType Directory -Path "C:\new-target-location\" + Select-Object Name
と私はこだわっています。私はその最後のビットを得ようとしています。とにかく、誰かが彼らの頭の中でより良いアイデアを持っているのだろうか?
ワンライナー: 'dir -Path C:\ some \ location \ * -Directory | %{New-Item -ItemTypeディレクトリ - パスC:\ another \ location \ -Name $ _。Name} ' – xXhRQ8sD2L7Z