I try to create un program that put files in a specific folder and rename them according to their date.
For exemple, in a first folder I have these files :
Valid_test1.pdf (created 05/07/2022)
Valid_test2.pdf (created 05/08/2022)
In_court_test3.pdf (created 05/02/2022)
I would like to put only valid test in a second folder and rename them. So I would like to have in a second folder :
If I got it right you want to either copy or move some files and rename them during this process, right? Until now you only showed some code where you display properties from files.
I’m pretty sure we can help you but you should show the complete code. Without that I’d recommend using a loop to iterate over all desired elements.
BTW: When you post code, sample data, console output or error messages please format ALL of it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.
You’re creating a list of files but you’Re not using it in your loop. And you’re setting the name of the destination of the move command outside the loop. If I got it right you can start with something like this:
With this code all of your files will end up directly in the destination folder. No matter if they have been in a subfolder of the source folder originally.
It’s intelligent to use Join-Path. The script isn’t finished, for better understand, it will put some files. And these files are published every day. From 10:00 AM, the file communicates informations for next day.