Rename files in for each loop .....?

my case:

-downloading 10 excel rapports from 10 different sites
-all of them have the same filename

I use a for each with array string of the URL’S.

after downloading each file needs a specific name!

how to make this in a already exist for each for the URL’S ?

Hello,

I hope you are downloading through a browser. So while downloading, along with the path, save with the name that you require. Usually the file gets downloaded into downloads and we can’t specify the path. You can change the settings like this:

Hope this helps!
Athira

yes but each download has the same name. so how to manage that?

How are you getting the new names for each file? Is it stored somewhere?

I have for each URL to download. but I need the renaming specific for each site

No, this is what I understand:
You have some urls in an excel file. After you download, all the files will have same name. But you want to change the name of each file in to some other name. Is my understanding right?
If yes, how are you determining the name of the files while renaming?

no I have 10 URL’s in array string.

then loop though them in a for each and downloading them

in this loop I want to rename the saved excel files. for example:

URL1 downloading excel then = Rename must be: Adidas
URL2 downloading excel then = Rename must be: Nike

and so on

Is it possible to save the Names also in an array and pass it while saving?

Thanks!
Athira

haha yes that’s my question.

how to make this? for each in for each I guess

2 for each is not required. In the first for each where you are looping through URL, set the index like this:

Then, while saving the file, pass the path like this (Considering Arr_FileNames is the array of filenames)- FolderPath+ArrFileNames(Index).ToString

Hope this helps!
Thanks
Athira

Hi @Nightowl_music,

In that case, a dictionary or a json string might be a better input. Where the key will be the filename you want and value the URL

JSON example :

{“File1” : “https://dummyurl”,
“File2” : “https://dummyurl”}

Dictionary

dict= New Dictionary (Of String, String) From {{“File1” , “https://dummyurl”}, {“File2” : “https://dummyurl”}}

Then in you for loop you can use the key and value of either the json or dictionary. Both will be iterables. For JSON you can use the json serialise activity so that the string is convert to a json object.

Hi @Nightowl_music

If the list of Url’s and the file name is static, You can keep the Data in Excel and loop through each row. row(0).ToString to Open the url and row(1).ToString to rename the file(Use Move File and provide the row(1).ToString) as your files are downloading with the same name.

url1| Adidas
url2|Nike
url3|Puma

my array url’s are strings in this for each. if I change this to Object. is not working anymore…

No need to change it to object, keep it as string itself and give the index value.

im beginner don’t know how to do that? Index is variable…

Create an integer variable called index and pass that in the Index property. That’s it :slight_smile:

I use wait download function in my for each URL.

I like to use the New Dictionary. how write this in my for each Url loop?

im a beginner.

thanks