我正在尝试递归地将所有文件从a:\
复制到b:\
,除了那些元数据存在于a:\list.txt
中的文件。 list.txt
模式为LastWriteTimeYYYY-MM-DD HH:MM:SS,size,.fileextension,例如:
2001-01-31 23:59:59,12345,.doc
2001-01-31 23:59:59,12345,.txt
2001-01-31 23:59:00,456,.csv
...因此,a:\
目录树中与这些元数据匹配的任何和所有文件都应不复制。
我似乎在使用Where-Object
时遇到问题,以排除list.txt
上的项目,但复制其他内容:
$Source = "C:\a"
$Target = "C:\b"
$List = Import-Csv list.txt -Header LastWriteTime,Size,Name
$Hash = @{}
ForEach ($Row in $List){
$Key = ("{0},{1},.{2}" -F $Row.LastWriteTime,$Row.Size,$Row.Name.Split('.')[-1].ToLower())
IF (!($Hash[$Key])) {$Hash.Add($Key,$Row.Name)}
}
$Hash | Format-Table -Auto
Get-Childitem -Path $Source -Recurse -File | Where-Object {$Hash -eq $Hash[$Key]}| ForEach-Object {$Key = ("{0},{1},{2}" -F ($_.LastWriteTime).ToString('yyyy-MM-dd HH:mm:ss'),$_.Length,$_.Extension.ToLower())
#$Key
If ($Hash[$Key]){
$Destination = $_.FullName -Replace "^$([RegEx]::Escape($Source))","$Target"
If (!(Test-Path (Split-Path $Destination))){MD (Split-Path $Destination)|Out-Null}
$_ | Copy-Item -Destination $Destination
}
}
答案 0 :(得分:0)
我建议您简化代码:
<div class="modalData" id="talentData">
<div class="modalOverlay"></div>
<div class="contentData">
<div class="dataContainer">
<div class="gr-2 gallery">
<div><img ng-src="{{product.images}}"></div>
</div>
<div class="gr-2 biodata">
</div>
</div>
<a href="#" id="closeData">X</a>
</div>
</div>