Move files and renames issue

Hi All Dev,
I have the problem regarding move files and rename.

I have use activities as below.

1 Assign
files = Directory.GetFiles(“path folders”) * files is string
date_stamp = System.DateTime.Now.ToString

2 for each * type Argument is string
s_files in files
3 Move file
form path s_files
to destination Destination+date_stamp+“.PDF” but not working

sample i have PDF many files in folder.

before move to destination folders
20190724_9077157489.PDF

20190724_9077157493.PDF

20190724_9077157495.PDF

Expected after moved
20190724_9077157489 24-09-2019 11:22:33.PDF

20190724_9077157493 24-09-2019 11:22:33.PDF

20190724_9077157495 24-09-2019 11:22:33.PDF

Thank you for advance.

@pjaiphak

We can’t use special characters colon : into filenames and it will give error. Instead of colon use some other character.

@lakshman
Thank you very much.

but i have new issue.

assign

System.DateTime.Now.ToString(“dd-mm-yyyy hh-mm-ss”)

Destination+d_stamp+“.PDF”

image

Have you reset the files after moving it? Meaning it must have been already moved, so you need to copy them back with the original names…

@Raghavendraprasad
Correct after moved i need reset files name and include date time.

As per the screenshot above, you are missing the file extension I guess

Hi @HareeshMR Could you please help advise.

Can you post the destination file name which you are providing for move file activity @pjaiphak?

@HareeshMR please see as below.

image

From path
files=Directory.GetFiles(“D:\ALL_RPA\BDF_Auto_Print_INV\Main_INV\BDF_INV”)
s_files = files

Destination=“D:\ALL_RPA\BDF_Auto_Print_INV\Main_INV\BDF_INV_ARC"
Destination+d_stamp+”.PDF"

yeah , you need to add a back slash (\) after the destination and the timestamp variable it seems

check the destination path once

Hi @HareeshMR
after retest
before move i have 3 files.
20190724_9077157489.PDF
20190724_9077157493.PDF
20190724_9077157495.PDF

after moved
24-05-2019 02-05-42.PDF

Expected
20190724_9077157495 24-05-2019 02-05-42.PDF
can’t get current file name but replace name with d_stamp. -__-"

So, you want to append the date and timestamp along with the previous name right?

Then do the following,

  1. You are getting the item which is full path,
  2. Use string manipulations to get the existing file name without extension
  3. Then assign the value to a new string which contains both values, like the previous value you got in step 2 and the date time stamp
  4. Then use it in the move file activity

Hi @HareeshMR
Thank you for advice. but i’m very young beginner for UiPath developer.
Can you guide line for use activities 1-4. i will adapt or apply to complete workflow.

Thanks.

  1. In for each loop you have, s_file will give you the full path of the file
  2. (s_file.split("\“c).Last()).split(”."c).First()) will give you the file name without extension and store in variable as fileName
  3. Use assign activity as value = fileName + dateTimestampVariable
  4. Then pass the value variable as the destination path

Hi @HareeshMR

Very Excellent. I have completed this work flow. Thank you very much for you help.

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