Move a file or Rename a file

studio

#1

I am trying to insert the following senetence
file.move(oldpath,newpath)

But I don’t know which activity I must use because I tried to use “Assign” but It is shown a windows “Expresion does not produce a value”

Which activity Can I use to Move a file?

Is there a way to Rename a file?

I don’t see in the options the method “Rename” for a file


How to move a directory and its files to a new path
Rename excel or any other file
ダウンロードしたpdfファイルを読み込みたい
#2

Hi Lucky
Please follow below steps
Activity Name :Invoke Method
Target Type : Microsoft.visualbasic.filesysytem

MehtodName :Rename

Go to Properties of Invoke method
Parameters:
Direction—Type-- -Value
-----In------- string – “OldFilename.txt”
-----In------- string – “NewFilename.txt”

Thanks
Udaykumar


Email Automation - Help Please
#3

There’s a MoveFile activity that does just that, no need for InvokeMethod.

For Renaming you “move” the file to the same folder, just with a different name.

As a sidenote - I’d recommend using System.IO.File type, method name Move instead of Ms.VB, since it doesn’t rely on VB specific implementation.

Regards.


#4

Thanks!!

In fact, I did that, I hat to move the file to the same folder but renaming it


Saving attachements from outlook, with new name
#5

hey @Lucky0906

as @andrzej.kniola said

For Renaming you “move” the file to the same folder, just with a different name.

it will do what you wants.

To move a file from one destination to other destination with a different name then just rename the file when filling in the destination path

MoveFileWithRenameUsiNgMoveActivity.xaml (4.3 KB)

Regards…!!


Rename web downloaded excel file and save in particular path
#6

The file name that I need to rename is not static. It changes daily.

How do I specify a wild card in the file name using the “Path” field in the “Move File” activity?


Can anyone kind-hearted help checking following post? -- Regarding changing file name and move file
#7

BoCoNdOn,

In a similar case I found it easier to create a MSDOS batch file to move files using wild cards. You need to use StartProcess activity to call the batch file with the MSDOS commands.

Hope it helps


#8

@BoCoNdOn What is the naming convention of your file?

you can always get the files by wildcard character using below logic

Directory.GetFiles("C:\Users\xyz\Desktop\files","DailyFile_*.txt") //DailyFile_040716.txt


#9

If you move a file or Rename a file you can use my software BatchRenameFiles Tool . It’s very easy to use .


#10

Good Job


#11

its giving error that filesystem dose not contain rename method.


#12

MoveFile Activity will help you in this .

Use the properties as below

From :- Path\Filename
Destination :- Path\RenamedFilename


#13

Hi Uipath angels,

Can I get a .xaml sample about how to handle case below?
The requirement is to find target file, change file name with not static string and move all of them to another folder.

The oringinal data is like following.
※※※In a word you can regard the first file name as title in each set, get the string between “~_00” and “.txt” and insert it into the place where “a,b,c,d,e,f,g” are.

20181202_HL00431_00_3837_000_000_name.txt
20181202_HL00431_01_a.txt
20181202_HL00431_02_b.txt

20181202_HL00441_00_3803_001_020_name1.txt
20181202_HL00441_01_c.txt
20181202_HL00441_02_d.txt

20181202_HL00555_00_3803_001_020_name1.txt
20181202_HL00555_01_e.txt
20181202_HL00555_02_f.txt
20181202_HL00555_03_g.txt