I want to rename the file which is downloaded to downloads folder.
Steps I followed:
Using Assign activity, I get the latest downloaded file using
str = String.Join(“”,Directory.GetFiles(dirFilepath_Source,File_Type,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1))
Using Move Activity, source location to destination location folder.
Here source location as “str” the place where downloaded file available but not sure on the filename and its randomly generated.
After download, reading one more data from the application and saving in a “variable”.
Rename file should look like “Variable”_Filename.
My requirement is to rename the filename and then move (or) move and then rename.
IsRenamed: It will give output as boolean value. It returns true if operation succeed else False.
Queries:
oldName I am not sure- It is randomly generated
My new name should be customText_oldFileName. Here the custom text also randomly generated from the web application.
If you know the exact file name in advance then it will works, what if file name should know once it is successfully downloaded and randomly generated from web application.
After move, assign the below string to variable1.
String.Join(“”,Directory.GetFiles(dirFilepath_Source,File_Type,SearchOption.AllDirectories).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Take(1))
You variable1 is having the latest file name along with the path like C:/A/B/C/Downloads/RandomlyGeneratedFilename
Create a array string variable.
Using split string method
StringVaraible.Split({“Downloads/”},StringSplitOptions.None)
Now your array string variable having the values are
array string variable(0) is having the value as “C:/A/B/C/Downloads/”
array string variable(1) is having the value as RandomlyGeneratedFilename
Move file activity Destination as: rename the file as
“customized string” + RandomlyGeneratedFilename