Moving files from one location to destination, not moving if file already exists in destination folder

Hi,

i am looking to move files from one location to a destination folder. If the file i am moving already exists in the destination folder, i don’t want to move it.

2 Likes

@Automater999

You can use the Move File activity. Make sure Overwrite is not enabled in the Properties panel.

1 Like

Hi @Automater999,

You can use the “Path Exists” activity. Just put your file path in the activity and you’ll retrieve a boolean (true/False). Juste check the boolean with an “if” activity to know if you have to move the file or not.

image

I wouldn’t know the name of the file

Hi
if OVERWRITE Option is enabled it will overwrite the already existing file
and if we dont wan to do that hope these steps would help you resolve this
–use a assign activity like this
arr_frompath = Directory.GetFiles(“yourfolderpath”)
where arr_frompath is a variable of type array of string
–againa assign activity like this
arr_destination = Directory.GetfFiles(“yourfolderpath”)
where arr_destination is a variable of type array of string

now use a FOR EACH activity with input like this
arr_frompath.Except(arr_destination)
and change the type argument as string in the property panel of for each loop
–inside the loop use MOVE FlLE activity and mention the path property as item.tostring and destination property with the folder path where we want to move

Cheers @Automater999

You can find in this .xaml, a sequence for your issue.

1 - Just assign the input folder and ouput folder
2 - The Directory.GetFiles will retrieve all files with full path
3 - Foreach the string array
4 - In the foreach, test if the file exist
5 - Move the file if nedded

As explained before by @Palaniyappan

MoveFile.xaml (7.0 KB)

Thank you. Works well

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