我有一个目录,我想递归地复制到另一个位置进行处理。似乎没有创建第一个目录。执行复制的程序部分如下:
# Read the source files to convert.
$lAllFiles = Get-ChildItem $lSrc -Exclude $lExcludedFiles
# Remove excluded directories
foreach ( $lExclusion in $lAllExcludedDirectories ) {
# If we have a wildcard use the -notlike operator to filter the list.
# Otherwise use an -ne operator.
if ( ($lExclusion -like '*' ) -or ($lExclusion -like '?' ) ) {
$lAllFiles = [array]$lAllFiles -notlike $lExclusion
} else {
$lAllFiles = [array]$lAllFiles -ne $lExclusion
}
}
# Start the log.
Start-Transcript -Path "$lJobLog"
# Copy the data to be converted to the conversion root.
ForEach ( $lFile in $lAllFiles ) {
Copy-Item $lFile $lCnv -Recurse -Force -ErrorAction SilentlyContinue -ErrorVariable +JobErrors -Verbose
}
.
.
.
当我比较源目录和目标目录时,看起来好像没有在目标中创建第一个子目录,并且第一个子目录的内容被写入目标。
举个例子:
The Source:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 1/6/2013 9:30 AM AP-LEDGER
d---- 3/12/2014 9:28 AM AP.DETAIL
d---- 8/20/2014 9:33 PM AR-LEDGER
d---- 9/3/2011 9:58 AM lost+found
-a--- 5/13/2016 9:21 PM 32768 AP-BATCH-CTRL
-a--- 5/13/2016 8:39 PM 291293184 AP-LEDGER-XREF
-a--- 9/28/2015 3:14 PM 8425472 AP.JDE
-a--- 5/13/2016 8:39 PM 150700032 AP.LINK
-a--- 5/2/2016 3:30 PM 52224 AP.QUEUES
-a--- 5/13/2016 8:17 PM 743018496 AP.SUSP
-a--- 4/30/2016 9:11 PM 51222528 ARROLLARC
-a--- 4/30/2016 9:11 PM 102404096 ARROLLFWD
-a--- 5/14/2016 3:29 AM 1016950784 A_Pa
-a--- 5/14/2016 12:37 AM 238280704 A_Ra
-a--- 5/14/2016 3:16 AM 61423616 GL-CROSS
-a--- 5/14/2016 3:16 AM 175235072 GL-INDEX
-a--- 5/14/2016 3:16 AM 21512192 G_La
-a--- 5/14/2016 3:16 AM 224661504 X_AP.SUSP
-a--- 5/14/2016 3:29 AM 150089728 X_A_Pa
-a--- 5/14/2016 12:37 AM 63578112 X_A_Ra
目的地:
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 5/26/2016 10:53 PM AP.DETAIL
d---- 5/26/2016 10:53 PM AR-LEDGER
-a--- 5/13/2016 8:38 PM 1073737728 dat001
-a--- 5/13/2016 8:39 PM 682541056 dat002
-a--- 5/13/2016 8:39 PM 1004023808 idx001
-a--- 5/13/2016 8:37 PM 41234432 over001
请注意,目录中的文件应位于文件夹 AP-LEDGER 中。到底是怎么回事?
-Recurse -Force 不创建目录吗?