2014-11-21 166 views
0

對源E使用Robocopy:會導致錯誤。所以,我希望得到一個路徑的子目錄(並且只有第一個子目錄)以後用Robocopy複製。獲取路徑中的一級目錄

mypath中

MyPath/Examples 
MyPath/Icons 
MyPath/Icons/Another/ <------- NO 

回答

2

喜歡這個?

$path = 'c:\mypath' 
Get-ChildItem $path -Directory 
0

Get-childItem支持通配符。所以這會得到一個深度的文件夾。

Get-ChildItem Mypath\* 

那麼你是在尋找這樣的事情:

$source = "Mypath" 
$dest = "$env:temp" 
$folders = Get-ChildItem "$source\*" -Directory 
$folders | ForEach-Object{ robocopy $_.fullname "$dest\$_" -E } 
0

使用的Robocopy與源E:導致錯誤。

是否這樣?它看起來不錯...

C:\>robocopy E: d:\t /LEV:1 /L 

------------------------------------------------------------------------------- 
    ROBOCOPY  ::  Robust File Copy for Windows 

------------------------------------------------------------------------------- 

    Started : 25 November 2014 
    Source = E:\ 
    Dest : d:\t\ 

    Files : *.* 

    Options : *.* /L /DCOPY:DA /COPY:DAT /LEV:1 /R:1000000 /W:30 

------------------------------------------------------------------------------ 

          13 E:\ 
      *EXTRA File    185  t.bat 
      New File     44  Track01.cda 
      New File     44  Track02.cda 
      New File     44  Track03.cda 
      New File     44  Track04.cda 
etc. 

您使用的是最新版本嗎?

答案:使用RoboCopy。