Help With moving files that ends with


I have a folder with several .pdf files and I need to move them to different folders according to the last letters of the file name.
I have a file that ends with “BO”
a file that ends with “NF”
and a file that ends with “RPS”
Would it be possible to accomplish this with a “Flow Decision”?
If yes, how?

Hello What I would do will be the next.
1.- Assing to Get the Files
2.- A for each
3.- An assign to validate what kind of file is (Firts Activity inside the For each)
4.- A Select case Activity validating the previous Assing (Second Activity inside the For each)
5.- Inside each Case the Move file Activity with the correct path

I’m sorry I didn’t really understand your explanation.
all i need to do is move the files to different folders according to the end of .pdf name

We can create switch statements after getting the text file each file names…could you please share the sample file name?

Those are the file names:

each will end with “BO”, “NF” or “RPS”.

@Leandro_Samuel - Here you go… I put 3 pdfs in my folder and extracted the last string from it…and stored in an erray…

StrArrayFileEndsWith = Directory.GetFiles("YourFolderName","*.pdf").select(function(x) path.GetFileNameWithoutExtension(x).split("_"c).last()).toarray

OR you can directly give the statement in the for each, as shown below…For Each type should string and Switch Activity Type should be “String”.

Hope this helps…

I know I’m asking too much, but could you upload your file? I think I’m getting lost in some step here

@Leandro_Samuel - just came outside…please post your screenshot on where you got lost…I will take a look…you just have to put your folder name in the code which I gave…thats it…you should be good…

it’s because I never used the “Switch” activity
he is giving me this error

@Leandro_Samuel - here you go…
MoveFile.xaml (7.1 KB)

I just tweaked it little bit…Hope this helps…

Yea! It works!
I saw where I was going wrong, thank you so much!
I noticed that some .pdf’s end with numbers. Example
“RPS1”, “RPS2”,“NF1”,“NF2”

But I think that from here I can reach my goal

Thank you so much!

Once you are done with your testing…please mark my post as solution, so that others will be benefited…

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