SOLVED

Move new arrived files from one folder to an other

%3CLINGO-SUB%20id%3D%22lingo-sub-150680%22%20slang%3D%22en-US%22%3EMove%20new%20arrived%20files%20from%20one%20folder%20to%20an%20other%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-150680%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3C%2FP%3E%0A%3CP%3EI%26nbsp%3Bneed%20a%20poweshell%20script%20that%20move%20all%20new%20arrived%20pdf%20files%20from%20one%20folder%20to%20an%20other%26nbsp%3Bfolder.%3C%2FP%3E%0A%3CP%3E-%20New%20pdf%20files%20detaches%20from%20email%20to%20d%3A%5Cdaownload%20folder%3C%2FP%3E%0A%3CP%3E-%26nbsp%3BA%20scheduled%20job%20looks%20twice%20a%20day%20in%20d%3A%5Cdownload%20folder%20and%20move%20all%20arrived%20pdf%20files%20to%20d%3A%5CPDF%20files%5C%3C%2FP%3E%0A%3CP%3EThanks%20a%20lots%20for%20any%20help%3C%2FP%3E%0A%3CP%3E%2FSoran%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-150680%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOneDrive%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-150729%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20new%20arrived%20files%20from%20one%20folder%20to%20an%20other%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-150729%22%20slang%3D%22en-US%22%3EThanks%20P.%20R.%20Ortiz%20!%20It%20works%20fine!%3CBR%20%2F%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-150697%22%20slang%3D%22en-US%22%3ERe%3A%20Move%20new%20arrived%20files%20from%20one%20folder%20to%20an%20other%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-150697%22%20slang%3D%22en-US%22%3E%3CPRE%3E%23get%20all%20pdf%20files%20in%20%22d%3A%5Cdownload%5C%20creqated%20in%20last%2012%20hours%0A%24Files%20%3D%20Get-ChildItem%20%22d%3A%5Cdownload%5C*.pdf%22%20%7C%20Where%20%7B%24_.CreationTime%20-gt%20(Get-Date).AddHours(-12)%7D%0A%0A%23Move%20files%20to%20%22D%3A%5CPDF%20files%5C%22%0AForEach%20(%24File%20in%20%24Files)%20%7B%0AMove-Item%20-Path%20%24File.FullName%20-Destination%20%22D%3A%5CPDF%20files%5C%22%0A%7D%3C%2FPRE%3E%0A%3CP%3Ethen%20create%20a%20scheduled%20task%20to%20run%20the%20script%20twice%20a%20day%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi

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

/Soran

2 Replies
Best Response confirmed by Soran Perotsur (New Contributor)
Solution
#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!