Hi I have PDF files in a folder that I want to join first based on the criteria on (10MB each).
What I am trying to achieve is if the file size reaches 10mb then it should create another file with the same name but add a counter to it? Please can anyone help? or if you have a sample workflow that would work for me too.
Eg: of filename -
1.) abc.pdf
2.)abc_v1.pdf
Note: Some of my pdf files have attachments so I can not use merge pdf activity.
Hi
First let’s get the filepath of all files in a folder
—now use a ASSIGN activity like this arr_filepath = Directory.GetFiles(“yourfolderpath”)
Where arr_filepath is a variable of type array of string
—now use a FOR EACH activity and pass the above variable as input and change the type argument as string
—inside the loop use a IF condition like this New System.IO.FilePath(item.ToStrings).Length > 10000000
If true it will go to THEN part where we can use Copy File activity and mention the filepath with the name we want in destination property
Thank you for that, however my task is a bit different. See screenshot attached. Based on the file size I trying to join all the pdf’s together which are less than 10mb (i.e file number 1, 2 and 3) and then have another file (file 4 in my case) since it is almost 10mb.
I have to upload these files to a portal in batches and the limitation is 10mb per file.
but do you want to put the PDFs together in like a zip file or really join to have only one PDF with the content of others until you have groups of 10MB?
I’m assuming he just needs to loop the upload process in groups. Like there is probably an add button to select file(s). He would just need to make an array of the files grouped by file size, then run that with the ForEach to call the upload part inside the loop.
But, if he wants to merge the groups to a pdf, then he would need to do the same thing, but would just need to either merge or zip the groups of files.
i guess i dont have so much creativity to understand some topics but that would be kind of easy to do creating a string list and adding file by file checking total size until reachs around 10MB…
Maybe you can make use of the C# code from this post - invoke in UiPath or by using the corresponding activities:
It will output the combinations from the array that sum to a predefined target. The array may store pdf file sizes, in your case, and the target - 10mb.
Then loop by decreasing the target - not very likely to reach exactly 10 mb.
thank you @alin.c.mihalea but this makes combinations of files but I need unique files. So does not help me much. Also, I am not well versed with coding.