Extracting the file path and creating the new folder with same file name for the downloaded file

Hi all
I have a scenario, where in a folder I have multiple text files. I have retrieved the file path of every text file one by one. Once the path of 1st text file is retrieved, using that path I am going to download a file(for example) which is going to be stored in the same location where the text files are available. I have to move the downloaded file to the separate/new folder with the text file name in it and then proceed with the next file with the same process.
Kindly help with this scenario. If possible could you please share Xaml file for this case.
Thanks in advance

Hi @Newton_Rich_SV

I have created a sample workflow for you. This gets a set of text files from a given folder. Then, for each file, it creates a another folder within the same source folder using the file name. Then it moves the file from the source to the destination folder we just created.

Check it out!! If this helps, please mark the answer as the solution so it could help others looking for similar solutions as well :slight_smile:

TextFileMove.xaml (7.0 KB)

Thanks for the solution.
It worked

1 Like

Hi @Lahiru.Fernando
Thanks for the support.
Here I have attached a xaml file.
What I was trying to do is, in a folder I have 2 text file. I am writing the path of the text file in the a notepad and saving it in the same location. I am doing this process twice. Two more txt files are created in the same folder. My requirement is moving the two newly created files to different folder and its name should be the file name which was available initially and written in the notepad. My xaml is wrong. Could you please correct me in which I am going wrong. Please let me know if there are any queries in the requirement. Attaching my xaml, please help me correct it based on my requirement.
ThanksFilees.xaml (28.4 KB)

Hi @Newton_Rich_SV

I went through the file… I have few concerns here…

  1. In the first For Each loop, you are creating two note pad files with the same path name in it. why do you have two note pad creations in the loop? In a for each loop, you can repeat the same steps for each item. So you could use only one set of that, and it will repeat the process for every file in the list.

  2. Once your file is ready to save, why are you saving in the same location in a different file name instead of directly saving it in the folder path you need it to be? It will be much more efficient to do it directly rather than creating and moving it again.

  3. your create directory path should have another “” if you want to create the folder within the “hiii” folder. In the current way, the folder is created externally like this…


  1. The concept of the second for each loop is wrong bro. It will actually return all four files including the old and the new. and, it will only return the file name for the “FIle” variable which will throw an error when you try to move because it is not searching in the appropriate file path…

You can actually do this entire thing in one For Each loop… try going through the sample I gave again. I think you might haven’t got the exact concept of For Each loop…

Let know if anything is not clear, would be glad to help you out…

Hi bro
Actually I am not clear. I will explain my actual scenario. I will be having few text files in a folder. I am going to use that text files path to download few files .There may be 3 to 5 files will be downloaded in the same folder where the inputs files will be available (I just created 2 notepad considering it as downloaded file). So I have to move those downloaded files to a separate folder. Name of the new folder should be the text file name. Please help me with this case bro.
Thanks in advance for your help.

HI @Newton_Rich_SV bro

I did some changes to the file I sent previously to support your requirement. I also have added a new text file creation and saving to simulate your download process just like you did. But I will be creating only one file here. and in the next loop, I used the same condition as you did to find the latest files. So basically, if the existing files (except the one we are creating) are also created on the same date, then they will also be moved to new folders. If they are files that are created before today, they will remain there and the new file will be moved without any issue. This happens because we are checking the file creation date here in the loop to find the latest files first.

TextFileMove.xaml (10.0 KB)

Hi @Lahiru.Fernando
I am getting few errors while applying your concept.
My folder name is Hiiiii and initial file names are Bala & Newton. I am creating the text file in the name Arun.
While creating directory, for me it is creating like foldername+filename (Hiiiiibala). And file is also not moving. I have attached the screenshot for your reference. Thanks for your help.Filees.xaml (13.8 KB)

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