Ich habe eine Frage. Ich habe eine Format-Tabelle mit Dateiname, Quell- und Zielverzeichnis erstellt. Jetzt versuche ich mit einer foreach durch die Tabelle zu laufen. Innerhalb dieser Schleife möchte ich die Dateien vom Quell- zum Zielverzeichnis verschieben. Mein Problem ist es, die Gegenstände aus der Reihe zu bekommen.Powershell Loop durch Format-Tabelle
Hier ist mein Beispielcode:
cls
$MovePathSource = "C:\Users\user\Desktop\sourcefolder"
$MovePathDestination = "C:\Users\user\Desktop\destinationfolder"
$filetypes = @("*.llla" , "html")
$table = dir $MovePathSource -Recurse -Include $filetypes | [email protected]{Expression={$_.Name};Label="Filename"},@{Expression={($_.DirectoryName)};Label="Sourcepath"},@{Expression={($_.DirectoryName).Replace($MovePathSource,$MovePathDestination)};Label="Destinationpath"}
$table
foreach ($row in $table)
{
write-host "$row.Sourcepath"
#Move-Item -Path ($row.Sourcepath + "\" + $row.Filename) -Destination $row.Destinationpath
}
dank verwenden! Das funktioniert! –