Hello everyone,
just started a few weeks ago with powershell so im pretty unknown to how everything works.
last week i was busy with the following script.
the scenario: i would like to copy certain file types from a folder and its subfolder to a created folder with todays date. that part i got that working
. for the next step there are 2 options 1: keep the duplicate file’s name and add -copy to it or 2: move all duplicate files to a folder withing the just created folder with todays date. it doenst really matter wich solution. after that i want a search range for example: in the directory C:.…\folder\ are more folder named user1, user 2, user 3 etc etc. i want to have a range that the script only searches in user1 til user 5, or only in user 20 til user 40.
i tried and tried and smashed my laptop a few times any help i really apreciated off course ![]()
this is what i got
$destination = "location to save"
$source = Get-ChildItem -Path "files where to look" -Filter "*.txt" -Recurse
$folderName = (Get-Date).tostring("dd-MM-yyyy")
New-Item -itemType Directory -Path $destination -Name $FolderName
foreach ($file in $source) {
Copy-Item -Path $file.FullName -Destination $destination$folderName
}
EDIT: removed $file_path