Move or Copy a File to a Directory that changes names every day

Hi all,

Currently i Have a Sequence in Uipath Studio, where i create a directory with the name " & now.tostring(“yyy-MM-dd”) so it changes names every day. Afther that in the same Sequence i Open the SAP Web Client and Dowload excell files. i need to move or copy those excel files to the created directory in the beginning of the sequence. but I dont know how to name the path. It keep giving me an error.Capture
This is the path that i give it. and in the ouput you can see the error that it shows.

Kind Regards
Athevan Kandasamy

@athevan96 try storing the path of the directory into variable after creating the directory, so you can use the variable to move the file. If i am wrong please correct me.

Thanks

When you will do "…Billing\A Daily Report\0 Historical\yyy-MM-dd” it will always create yy-MM-dd file and not a folder
You will need to pass the file names for both the cases

1 Like

as in pass you mean not name them in the path

Also the excel file i have to download changes names as well do you know how can put that in the path as well?

Suggestion:Use a create directory using path.combine

Take a variable path= Path.Combine(folderpath,Now.ToString(“yyyy-MM–dd”))

Take a Create Directory activity and in that pass the variable - this will create your directory

Now in your forEach
you are doing a copy
so
Source = youfolderpath+fileName(this is already getting you the file name)
Targte = path+“\”+fileName

Can you also tell me how you are getting your fileNames?

1 Like

Hi Nadim
here are picture of the sequence i have now maybe you could see what im doing wrong


I’m having a hard time getting the file names
Do you maybe have a demo where i can see how its done correctly cause if been trying to solve this but i just dont understand what i have to do or how i link the variable’s to the path.

Kind regards
Athevan

1 Like

Ok @athevan96 I have a simpler approach that i have used previously.

What you have to is get rid of the double-clicks that you are doing -Ideal case its not required
Also you wont have to do a move or copy :slight_smile:

So here here is what you do:

folderPath- path where u want to create currentDate folder and store your files

  1. Create new string variable - downloadPath = Path.Combine(folderpath,Now.ToString(“yyyy-MM–dd”))
  2. Create Directory - pass download path
  3. Then you have your Open Browser
    … a. Click 1 (your item)
    … b. Delay
    … c. Click 2 (export icon)
    … d. Click 3 (Yes button)
    … e. Click 4 (File tab)
    … f. Click 5 (Save As)
    … g. Click 6 (Browser)
    … h. Here you add a Get Text activity and get the text from the File name field

    Add a variable to store the fileName

… i. Add an assign activity and assign the below:
filePath( this is a new variable) = path.Combine(downloadPath +""+fileName)

… j.Here you add a type into activity and indicate the same File Name field and pass filePath variable as input

…k. Click 7 (Save)
…l. Click 8 (Yes)

Rest all you can remove.
So your seq looks likes this
image
.



image

Let me know if this was helpful

2 Likes

Hi Nadim,

First of all Thank you for your fast reply and thinking of ways to help
I’m going to try it right now. But with the 1. create new string variable - download path = Combine (folderpath, now. tostring(yyyy-MM-dd")). Do you mean i have to create a Variable and put the destination and file name in default? and what should the variable type be

1 Like

Variable type will be string and if not default you can otherwise use a assign activity to set the value :slight_smile:

1 Like

Hi Nadim

Again Thank you for helping solve this problem
I think you are very close to solving it :grin:.
So i did what you said and it looks like this now



But for some reason it doesnt save the excel file in the desired directory and it changes the name instead of just saving it in the desired directory

this is what happens

this is the folder were the excell file shoud be saved in

:sweat_smile: im gonna solve it :nerd_face:

Change required here
downloadPath = Path.Combine(folderpath,""+Now.ToString(“yyyy-MM–dd”))
Because you dont have a \ in your default path variable

And please show me what both the create director and filePath assign looks like where you have used path.combine

1 Like

you are right i forgot the \ so ther directory is created in the right place now

![Capture1|690x307]
for the firts image i added the \ so that shoud be fine now
(upload://eyqKUdfNQSGZubRdMRloNYYEwKa.png)
these are the assign filePath looks like

1 Like

Sorry i missed the \ as i forgot to escape it in the message here

Please use like this
filePath= path.Combine(downloadPath +“\”+fileName)

1 Like

So afther adding the \ it saves it here


So almost al i should be doing now is adding one more \

1 Like

Yes, just like i said above, in the next path combine (my mistake :stuck_out_tongue: )

1 Like

haha i see, i’m trying it now, hopefully it works

Thank you very much it’s working !!!

1 Like

Achieved! :slight_smile:

[please mark answer as solution and close thread]