Updates

mail@pastecode.io avatar
unknown
powershell
a month ago
709 B
2
Indexable
Never
$allFiles = Get-ChildItem -Path 'C:\Users\blair\Desktop\test' -Filter 'IPK_*.xlsx' -File
$excl     = New-Object -ComObject "Excel.Application"
$excl.DisplayAlerts = $false

foreach ($file in $allFiles) {
    $wrkb = $excl.Workbooks.Open($file.FullName)
	Start-Sleep -Seconds 5
    $wrkb.Save()   
    $wrkb.Close()
}

$excl.Quit()
$null = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wrkb)
$null = [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excl)
[System.GC]::Collect()
[System.GC]::WaitForPendingFinalizers()

[System.IO.Directory]::SetLastAccessTime($DestinationFolderPath, $NewDate)
[System.IO.Directory]::SetLastWriteTime($DestinationFolderPath, $NewDate)
Leave a Comment