Anlage des Repos
This commit is contained in:
60
test/Move-Files2CreationDateFolders.ps1
Normal file
60
test/Move-Files2CreationDateFolders.ps1
Normal file
@@ -0,0 +1,60 @@
|
||||
#MK / 15.01.2021
|
||||
cls
|
||||
|
||||
[String]$Sourcepath = "E:\KammM\PS2EXE-GUI - Kopie"
|
||||
[String]$Targetpath = "E:\KammM"
|
||||
|
||||
[Array]$Items = $NULL
|
||||
[String]$ItemFinalPath = $NULL
|
||||
[String]$ItemLastWriteTime = $NULL
|
||||
[String]$DateSeperator = "/"
|
||||
[String]$ItemYear = $NULL
|
||||
[String]$ItemMonth = $NULL
|
||||
[String]$ItemDay = $NULL
|
||||
|
||||
$Items = gci $Sourcepath -Filter *.* #-Force -Recurse
|
||||
|
||||
FOREACH ($Item in $Items) {
|
||||
|
||||
Write-Host "-------------------------------------------"
|
||||
Write-Host "Processing File: $($Item.fullname)"
|
||||
|
||||
Write-Host "Attributes: $($Item.CreationTime)"
|
||||
Write-Host "Attributes: $($Item.Attributes)"
|
||||
Write-Host "Attributes: $($Item.LastAccessTime)"
|
||||
Write-Host "Attributes: $($Item.LastWriteTime)"
|
||||
|
||||
$ItemLastWriteTime = $($Item.LastWriteTime)
|
||||
|
||||
$ItemLastWriteTime = $ItemLastWriteTime.Split(" ")[0]
|
||||
$ItemYear = $ItemLastWriteTime.Split($DateSeperator)[2]
|
||||
$ItemMonth = $ItemLastWriteTime.Split($DateSeperator)[0]
|
||||
$ItemDay = $ItemLastWriteTime.Split($DateSeperator)[1]
|
||||
|
||||
$ItemFinalPath = $Targetpath+"\"+$ItemYear+"\"+$ItemMonth+"\"+$ItemDay
|
||||
Write-host "Targetpath: $($ItemFinalPath)"
|
||||
|
||||
IF (($ItemLastWriteTime) -and ($ItemYear) -and ($ItemMonth) -and ($ItemDay)) {
|
||||
|
||||
Try {
|
||||
|
||||
New-Item -Path $($ItemFinalPath) -ItemType container -ErrorAction SilentlyContinue
|
||||
|
||||
If (Test-Path $($ItemFinalPath)) {
|
||||
|
||||
$Item | Move-Item -Destination $($ItemFinalPath) -Force
|
||||
}
|
||||
|
||||
} #end try
|
||||
|
||||
Catch {
|
||||
|
||||
Write-Error $Error.Item(0)
|
||||
|
||||
} #end catch
|
||||
|
||||
} #end if
|
||||
|
||||
} #end foreach
|
||||
|
||||
Remove-Variable * -ErrorAction SilentlyContinue
|
||||
Reference in New Issue
Block a user