I am trying to rename files in a folder- call it ‘Section I Documents’ where the roman numeral I tells the bot the files should start with roman numeral I
The folder will always have a roman numeral, like I, II, III, IV, V in it’s title and I need the files in that folder to begin with the roman numeral of that Section folder.
Roman Numeral I Section files should always begin I followed by _ → I_
II Section files follow the same pattern II → II_
Example Section I Documents
First file name = 1. Shopping_cart
New file name should be = I_1 Shopping_cart
Another example might be = 1a. Shopping_cart
New file name should be = I_1_a Shopping_cart
Thanks in advance for your help in guiding me how to do this!
Good point. I’ll clarify. There might be a letter after the number and there needs to be an underscore between the two ex. I_1_a and the period is removed.
This is an effort to rename files when they don’t match the naming convention. If the file starts with a roman numeral, it doesn’t need to be changed. If the file name starts with a number then I want to rename it using the rules in the above thread.
Business Cards in the Section I Documents folder → I_1 Business Cards
add the roman numeral I, underscore, the number, and period is removed
1a. Shopping Cart → I_1_a Shopping Cart
add the roman numeral I, underscore, the number, underscore, the letter, and period is removed
@Jessica_Moseley - Thanks for the info. I have started considering all the roman values so that you dont have to change the code in future…I will share the xaml soon.
@Jessica_Moseley - I am almost done, just need to insert underscore for 1b 1c cases…so thinking of the options…for the timebeing keep this output and explore the options…I will work on this tonight again…
RegEx Explanation: (^\S{2,}) matches any non-whitespace character - So this group will hold either 1. or 1a. because after this there is a space in the file name so it stops. This is group1. $1 in the screenshot
.* → matches any character (except for line terminators) = This is our Group2. $2 in the screenshot.
Code: I am checking the count for the group1 if its length (1. = 2, 1a. = 3 also has alphabets, 100.=4, 10a. = 4 also has alphabets 10. = 3, etc )
Based on this length I am carefully inserting the _ as per requirement.
I am working on version 18.4.6 and cannot upgrade it. The Regex matches sequence is saying Missing or invalid activity.
My UiPath.System.Activities by UiPath is version 18.4.2. I tried updating to versions 19.2.0 and 10.10.1 and it only made the problem worse.
UiPath.UIAutomation.Activities v18.4.5
@Jessica_Moseley - Here you go…Replaced the Regex Matches with simple Assign activity , as shown below…and used the same variable so that I don’t have make lot of modifications…
@Jessica_Moseley - Glad to help you…Actually I am very happy with this project, I made me think multiple ooptions and also gave me an opportunity to explore…