回复 2# Kira_1984
试一下 这个可以帮到不- $Destination = '\B\'
- $SearchText = 'ABC'
- if (![System.IO.Directory]::Exists($Destination)) {$null = New-Item $Destination -type directory}
- $Excel = New-Object -ComObject Excel.Application
- $Excel.Visible
- $Files = Get-ChildItem ".\A\*.xlsx" | Select -Expand FullName
- $f = ForEach($File in $Files){
- $Workbook = $Excel.Workbooks.Open($File)
- If($Workbook.Sheets.Item(1).UsedRange.Find($SearchText)){
- $File
- }
- $workbook.close($false)
- }
- $f | Move-Item -Destination $Destination
- $Excel.Quit()
复制代码
|