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
#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


#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?


#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