需要学习资源,请点击开挂教学楼
需要学习资源,请点击开挂教学楼
I have a powershell script that I am writing where I need to keep daily backups for the current month, end of the month backups for the year, and remove anything other than that.
$ThisYear = (Get-Date).year
$DailyLogs = (Get-Date).month
#Clean-Up Old Backup Files
Get-ChildItem 'D:\' | ForEach-Object {
if ( $_.LastWriteTime.Year -gt $ThisYear) {
Remove-Item
}
Elsif ( $_.LastWriteTime.Month -gt $ThisMonth -and $_.LastWriteTime.Date -ne ) {
Remove-Item
}
So far this should remove any backup files that are not from the current year. The piece I am trying to solve is how to delete the daily backups except for the backup files for the end of each month after the current month. I am stuck about how to get the -ne to the last day of any given month part.
Edit:
#Clean-Up Old Backup Files
Get-ChildItem 'D:\Server Backup\' | ForEach-Object {
if ( $_.LastWriteTime.Year -gt $ThisYear) {
Remove-Item
}
Elsif ( $_.LastWriteTime.Month -gt $ThisMonth -and $_.LastWriteTime.Date -ne [System.DateTime]::DaysInMonth($_.LastWriteTime.Year, $($_.LastWriteTime.Month))) {
Remove-Item
}
}
Based on Lee's comment here is my idea.
I used a draw
function to draw a rectangle in the image.
def draw(image, location):
...
cv2.rectangle(image, ...)
return image
Since there are many locations
of rectangles, I used the map
function to draw those rectangles.
list(map(lambda x: draw(image, x), locations))
However, this function is executed serially. This means that the speed is very slow. Is there a way to draw rectangles on the same image in parallel?