How do we extract a substring from a file, use it in to check if it contains a string and move it to another folder?

In_Desktop = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Desktop"

PathToProject = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)+"\Desktop\Project"

NoYearFiles is a new folder on the Desktop inside Project Folder
I want to move the File from Project to NoYearFiles

This is because your ‘To’ field is a folder path, not a file name.

The Move File activity specifies that ‘To’ field is also a filename field, not just the folder destination.
This enables a user to rename the file simultaneously.
If you want to keep the same filename in the new location, use the same string (or better yet, create a variable for reusability).

I hope this solves your problem.

1 Like

Thanks for your reply, but I want to make my From to be a file name and my To to be a folder name. I just cant get it right

In this case, I think you don’t really have a choice.
By that, I mean, the activity expects a filename as input, not a folder as input. When you provide a folder name as input, it considers that as the filename and tries to create a file by name NoYearFiles (no extension).
This is not expected behaviour.

If you don’t want to change the filename (and from screenshot, I get the sense that you already know the filename since you’re passing it in the ‘From’ field) then just use the same string after
PathToProjectFile + NoYearFiles + "<Filename>.<ext>"
Or alternatively
Assign → strFilename = "<Filename>.<ext>"
From → In_Desktop + "\Sorting_Annual_Reports_Project\.........\" + strFilename
To → PathToProjectFile + NoYearFiles + strFilename

1 Like

Thank you very much, actually the problem is that I was mentioning the from and to path twice. The program is already running inside that Sorting_Annual_Reports_Project.
So I was moving from FileA to FileB, like you stated it must be like
From> StrFilename
To> FileB
Mentioning the whole path was creating PathPathStrname
Thank you very much.

1 Like

Glad to be of help.
Happy automation!

1 Like

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