Move new arrived files from one folder to an other

Copper Contributor


I need a poweshell script that move all new arrived pdf files from one folder to an other folder.

- New pdf files detaches from email to d:\daownload folder

- A scheduled job looks twice a day in d:\download folder and move all arrived pdf files to d:\PDF files\

Thanks a lots for any help


2 Replies
best response confirmed by Soran Perotsur (Copper Contributor)
#get all pdf files in "d:\download\ creqated in last 12 hours
$Files = Get-ChildItem "d:\download\*.pdf" | Where {$_.CreationTime -gt (Get-Date).AddHours(-12)}

#Move files to "D:\PDF files\"
ForEach ($File in $Files) {
Move-Item -Path $File.FullName -Destination "D:\PDF files\"

then create a scheduled task to run the script twice a day

Thanks P. R. Ortiz ! It works fine!