My code will move item from an existing structure to a new one. For this it has to take many Folders and merge it to one. Sometimes there is a Folder which exist. My script will now go inside the sourcefolder copy the stuff inside and move it inside the existing Folder. This works pretty well except if the Folder are named for example "1datei" or "1temp"
If These Folders dont exist it creates them. so far so good. if this Folder exist it should go inside and copy all the stuff. For all the other Folder it works like Destination: "_v-test" exist? no? create it! Destination: "_v-test" exist? yes? move in source: "_v-test" and take out all the files inside to the new Destination.
Why would it work for all files except one with Name "1datei"? Is the number 1 a placeholder or something?
if ($aktuellerdstordner.name -like $archiv2)
{
$archivordner = get-childitem $aktuellerdstordner.FullName
foreach ($archivordnerinhalt in $archivordner)
{
if (-not (test-path ("{0}{1}" -f $ABenutzerakten, $archivordnerinhalt.name)))
{
new-item -force -path ("{0}{1}" -f $ABenutzerakten, $archivordnerinhalt.name) -type directory | out-null
}
$archivordnerinhaltnamen = Get-ChildItem $archivordnerinhalt.fullname
foreach ($archivordnerinhaltname in $archivordnerinhaltnamen)
{
if (-not (test-path ("{0}{1}{2}" -f $ABenutzerakten, $archivordnerinhalt.name, $archivordnerinhaltname.name)))
{
new-item -force -path ("{0}{1}{2}" -f $ABenutzerakten, $archivordnerinhalt.name, $archivordnerinhaltname.name) -type directory | out-null
}
move-item ("{0}{1}*" -f $aktuellerdstordner.FullName, $archivordnerinhalt.name) -Force -Destination ("{0}{1}{2}" -f $ABenutzerakten, $archivordnerinhalt.name, $archivordnerinhaltname.name)
}
}
}
Maybe my script is confusing started a week ago but except for the named Problems it works fine.
برچسب:
نویسنده: استخدام کار