fix folder deletion
This commit is contained in:
parent
0b63a079c3
commit
ab3fbffccf
@ -32,9 +32,10 @@ foreach ($file in $files) {
|
|||||||
Move-Item -Path $file.FullName -Destination $dest -Force
|
Move-Item -Path $file.FullName -Destination $dest -Force
|
||||||
Write-Host "Moved $file"
|
Write-Host "Moved $file"
|
||||||
|
|
||||||
# Remove the source folder if it is empty
|
# Remove the folder the video was in if it is empty, and is not the source folder
|
||||||
if (!(Get-ChildItem -Path $from -File -Recurse)) {
|
$folder = Split-Path $file.FullName -Parent
|
||||||
Remove-Item -Path $from -Force
|
if ($folder -ne $from -and (Get-ChildItem -Path $folder -File).Count -eq 0) {
|
||||||
Write-Host "Removed the folder $from, it is empty"
|
Remove-Item -Path $folder -Force
|
||||||
|
Write-Host "Removed $folder"
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user