Move File with Unique Name

Hi, I would like to move a file from one folder to another folder. But the file has a unique name based on the time stamp it downloaded the file. Can anyone help me on how can I move this file?

Are you trying to move a specific file? if so, you can directly use move file activity to move your file in the destined folder. if set of files, you can use *.pdf or *.xls with extension and move all the files.

@NAJAA_BAZILAH,

Plz follow below weblink and try with your requirement you would succeed,

@Pankaj.Patil - i believe, she is trying to move a file with the timestamp added to it. Not sure if its one file or multiple. The link which you have provided is to rename the file with timestamp correct?

@Pradeep.Robot,

Yes, We can use either copy file or move file activity to rename file as well.
we could give any name in destination property of above activities that you wish.

Yes, but the issue is finding the unique file that needs to be moved (which has unique timestamp on it).

@Pradeep.Robot,

I’m sorry I missed that point :frowning: .

We can use GetFiles method to get all files from specified folder like below,

// Create String Array variable
strArrFiles = Directory.GetFiles(“Your_Folder_Path”, Now.ToString(“dd.MM.yyyy”)+“*.xlsx”)
// Use for each to iterate over files
For each file in strArrFiles {
if Path.getFileName(file).Contains(Now.ToString(“dd.MM.yyyy”))
// do your work here
}Else{
// do your other work here
}

I gave example. I have files in Download folder with the file location: C:/robot/temp/Country_Data_10,Jul,2021_1,45pm.csv

I want to move this file to another location and rename the file with other name in shared drive:
H:/robot/classify/Country_Data_1.csv

The file is not only one file. It does have specific name each time data is download

@NAJAA_BAZILAH,

Just clarify my question now.

Do you want to move which is just downloaded by bot OR does download folder already contain many files?

Just downloaded by bot.
Each time the bot download, I want to directly move the file to another location and delete the file in the download folder. Then bot will continue download next data.

@NAJAA_BAZILAH,

Great,

use below code,

// Create String Array variable
strArrFiles = Directory.GetFiles(“Your_Download_Folder_Path”, “*.csv”)
// Use for each to iterate over files
For each file in strArrFiles {
// Use move file activity to move file which just downloaded.

Try to follow explanation you will get.

I am able to solve it by using this code and idea you provided and make some changes according to my needs. Thank you for helping :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.