- I need to access excel files that downloaded from a web browser that get put into the download folders and move them into another file path area.
- There are 4 files and they say Export.xls, Export (1).xls, Export (2).xls, Export (3).xls. I need to create a loop so they can read those files in the download folder and move and rename them into a different folder.
So how can I get the automation to read the files in the download folder with the numbers in parentheses to be able to move them into another folder path and rename them. I am able to rename and move the first Export without the numbers after it, but I can’t figure out how to get it to read the other files with the numbers in parentheses as well.
Create a For Each loop on
MyDir is the string representation of the directory where your files are located. This will read the files in your directory.
I keep getting an error saying that the Directory is not a member of System
Ah, I forgot the IO. It should be
It keeps trying find the files in my documents folder instead of the download folder which is not what I want. How do I get it to read the files in the downloads folder on the PC?
MyDir has to be set to the path of your Downloads folder.
Do you know what I would put in the Move File From? I want to be able to move all of those files in the downloaded folder into another folder. Is this the right activity to use for that?
“From” would be the full path of the file you’re moving. So if you’re getting the files using the GetFiles method, you would put the item from the For Each loop in that location.
The destination would be the parent directory (e.g.
ParDir) with the file name added. So the destination would be
String.Concat(ParDir, "\", System.IO.Path.GetFileName(Item)), where
Item is the item in the For Each loop.