First time poster, I’ve tried reading some of the training documents and searched the forums for something similar but I couldn’t really find anything so hoping someone can help please.
I’m grabbing an excel file off an application which extracts the file to my downloads folder titled “report”+lots of random numbers. Therefore I want to move this file to another folder and rename it with today’s date.
Is there a way to use wildcard on the move file activity to look for the file that starts with “report”?
I’m sure that it’s just late and my mind isn’t working but any help would be appreciated.
What I’m trying to do is move all files named as "file_name(some_time_stamp).csv, for the time stamp I will use wildcards, because it changes depending on the downloading date, then when founded the file to be moved I want to move it to another folder, and save it as “file_name.csv”.
The Move File doesn’t support wildcards, but you can use EnumerateFiles() or GetFiles() to get all files that meet your pattern using the wildcard. Then, run the list of files it found through a ForEach with the MoveFile inside.
Using example in my previous post would be something like the below pseudocode:
Declare variable: srcDir = "\\serverdomain\directory\foldername"
Declare variable: destDir = "\\serverdomain\directory\foldername2"
Declare variable: fileKey = "file_name"
// ForEach activity with TypeArgument String:
For each file In Directory.EnumerateFiles(srcDir, fileKey+"*.csv", SearchOption.AllDirectories)
Move File // From: file, To: Path.Combine(destDir, Path.GetFileName(file))
Thanks for your valuable help on this, moving file worked perfectly for me in the flow I am designing, I just need two things more, after my file is downloaded by using the Open Browser activity and the download URL, the downloading process in chrome lasts, 1 minute aprox, so before the file is stored in srcDir, the robot continues with the For Each activity, thus the moving file is not done because it is not found, due to it haven’t been downloaded by that time. Even though, I am not getting any error, so I would need a step that waits until the file is downloaded, and then continue with For Each activity and move the file, I tried with Delay activity, but after downloads, never stop.
Another thing I want to do is move the file to destDir without the timestamp on the filename, e.g it must be moved as filename, instead of filename_YYYYMMDDhhMM, this is the default download name from the system. What should I add to Path.Combine(Crosscheck, Path.GetFileName(file)) string?
The Timespan you used on the Delay was done wrong
I think it should be 00:00:65
which says 65 seconds
However, I don’t recommend using hardcoded delays. But, I understand if you don’t know what the filename will be after you download (unless you can get it to download and let you specify the filename, like for example if it’s in Chrome, you need to enable the setting so it will prompt you where to download the file). Using this approach let’s you choose the filename, and then you can check for the file to be completely downloaded with a more dynamic approach like a Retry scope with File Exists inside it.
Looking over what I posted above, I see that I suggested you store the “filename” to a variable, which I called filekey. So, for destDir, you can use Path.Combine(Crosscheck, Path.GetFileName(fileKey))
where Crosscheck is the destination direction and fileKey is the new filename you would like.