Hello,
I cant seem to figure out how to create same tree folders for my output merge.
I have 20 folders with pdfs beggining with a unique 24 chars code. I want only to merge pdfs from that folder into an output folder with same name.
EX:
letters\john\20210000542 letter.pdf
letters\john\20210000542 appendix.pdf
letters\john\20210000589 letter.pdf
letters\john\20210000589 appendix.pdf
letters\michael\20210000542 letter.pdf
letters\michael\20210000542 appendix.pdf
Output:
lettersoutput\john\20210000542 letter.pdf
lettersoutput\john\20210000589 letter.pdf
lettersoutput\michael\20210000542 letter.pdf
Im stuck at merging all files with that code and cant set a desired folder path. i dont want pdfs with same code from other folders to get merged just the ones from that folder.
thank you!
Hi
Welcome to uipath forum
For folder creating we can use CREATE FOLDER activity
and create the one we need and mention the same in the below activity
https://docs.uipath.com/activities/docs/join-pdf-files
This activity will help us join all the list of pdf files by mentioning the list of filepaths of that folder
So the steps involved will be
—use a assign activity like this
arr_filepath = Directory.GetFiles(“yourfolderpath”)
Where arr_filepath is a array of string variable
—use a CREATE FOLDER activity to create the folder we want
—then use this arr_filepath.ToList variable as input to JOIN PDF activity and mention the above created folder as well
Cheers @robert.cristian
@robert.cristian - Please try like below…
My Input Folder and Files - Like you shown above…
For Each - Type Argument → String
Directory.GetDirectories("Letters\")
Inside For Each, first use Create Folder activity. Below code will create John and Michale folders under LettersOutput folder
"LettersOutput\" + path.GetFileNameWithoutExtension(eachfolder)
Join PDF Files…
File List = Directory.GetFiles(EachFolder)
OutputFileName = "LettersOutput\" + path.GetFileNameWithoutExtension(eachfolder) + "\" + path.GetFileNameWithoutExtension(Directory.GetFiles(Eachfolder)(0)).split()(0) + " Letter.pdf"
My Ouptut
Hope this helps…
Thank you all for your input, im almost there. At the moment its joining all pdf in folders i want separate files for each letter&appendix with same code. If i have 2 letters and 2 appendix for ex. it joins all of them
Should figure it out doesnt seem to complicated. For my other project i used merge pdf instead of join and i had to use matching files in order to obtain this
But this is what you initial requirement right???
“Output:
lettersoutput\john\20210000542 letter.pdf
lettersoutput\john\20210000589 letter.pdf
lettersoutput\michael\20210000542 letter.pdf”
Please show us or share a sample structure for input and output…
So i have these letters:
F files:
G Files:
As you can see i have the 201500000000000134110000 code both in F and G folder
I dont want to merge from both directories just the ones in the same dir and the outcome should be:
Output\F\201500000000000134110000 13411_2015 letter.pdf
Output\F\201500000000000134770000 13477_2015 letter.pdf
Output\G\201500000000000134110000 13411_2015 letter.pdf
Output\G\201600000000000077550000 7755_2016 letter.pdf
From joining them i got only one pdf with all letters in each outcome folder like this:
one pdf with all 4 pdfs from the source directory
@robert.cristian - This is very tricky …but somehow I have managed to do it with one exception…
First I am reading all the files in the Letters folder and renaming any with " letter" with spaces…So this will give me as belowl
letters\john\20210000542.pdf
letters\john\20210000542 appendix.pdf
letters\john\20210000589.pdf
letters\john\20210000589 appendix.pdf
From this I am getting unique file name pdfs and getting second copy file and merging them together…
Merge_PDFs_UsingUniqheChars.zip (460.4 KB)
If you run the attached workflow as is, you will lettersoutput folders gets created with the merged pdfs inside.
Hope this helps…
1 Like
Works like a charm! Thank you very much! Really apreciate the help
1 Like
system
(system)
Closed
September 11, 2021, 10:58am
9
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.