In this scenerio bot will extract all the data’s from the PDF’s and then bot will convert that pdf’s extracted data into txt file…So user will daily run this bot and it will daily convert extracted pdf’s text to txt file,how can bot will read the latest generated txt file daily?..what code should i pass in read txt activity?
use this to get latest created txt File
Directory.GetFiles(folderPath,"*.txt").OrderByDescending(Function(d) New FileInfo(d).CreationTime)(0)
You can use this Query,
Text_filepath = Directory.GetFiles(folder_path,“*.txt”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
Regards.
@pratik.pandya what code should i pass in append line so bot would convert all the extracted pdf text into one txt file?
@Priyesh_Shetty1 For Getting the Text in One Text File Just Simple Concat the Text…Like Variable_1+ Variable_2
And if Want to Append it…Variable_1+ Enviroment.NewLine+ Variable_2
Please help me with this scenerio…In this case user will run the bot 2 times a day in morning and in the evening… So i have extracted Multiple pdf’s from the website and i have read all the pdf’s,know i have to generate the extracted PDF’s text in a txt file and bot will read only latest txt file only it should not read previous txt file…
Check below for your reference
str_filepath = Directory.GetFiles(yourfolder_path,“*.txt”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
Above will always give the file path of the latest file
Hope this may help you
Thanks,
Srini
I merged similar topics.
with help of append line i have appended all the pdf data and i have converted them in a txt file also with the help of append line activity…But i want date and current time in a file name…And previoused runned txt file should get deleted how should i do this?
@Priyesh_Shetty1
If you want to rename the file use “Rename File” Activity. Shown below is the way to add Date and time in the file name.
Can you try these steps-
- After converting the PDF’s extracted data into a .txt file using UiPath activities like “Read PDF Text” and “Write Text File”, you can save the .txt file with a dynamic name that includes the current date and time. For example, you can use the “Now” function in UiPath to get the current date and time and format it to include in the .txt file name. Here’s an example:
DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt"
This will generate a .txt file name with the current date and time appended to it, such as “20230420_123456.txt”.
2. Store the dynamically generated .txt file name in a variable using the UiPath “Assign” activity.
3. To read the latest generated .txt file daily, you can use the UiPath “Directory.GetFiles” activity to get a list of all .txt files in the directory where the .txt files are saved. Sort the list based on the file creation date in descending order to get the latest file on top.
4. Use the UiPath “Read Text File” activity and pass the file path of the latest .txt file (which you retrieved from the sorted list) to read its contents.
@Nitya1 Bot will just generate only one txt file and inside that txt file i want to append all the exrtacted pdf text…
I dont want to generate multiple txt file.
did you try with below expression?
str_filepath = Directory.GetFiles(yourfolder_path,“*.txt”).OrderByDescending(Function(d) New FileInfo(d).CreationTime).Tolist(0)
If so didn’t you resolve your issue?
Let me know if you are facing any issue
Thanks,
Srini