Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
12 lines (9 sloc) 474 Bytes
## If importing a file, and only needing to import the latest file, this will remove all older files and keep the most recent file
## Put this in a step before the import
Function RemoveEarliestFiles($loc)
{
$fs = Get-ChildItem -Path $loc -Recurse | Where-Object {$_.PsIsContainer -ne $True}
$fs | Sort-Object LastWriteTime | Select-Object -First ($files.Count - 1) | Remove-Item
}
## Put the file location below:
RemoveEarliestFiles -loc "C:\OurFileLocation\"