I need to create a folder based on the user input, capitalise it, check for matches and then check for a unique code.
If the name begins with ‘The’ then that needs to be removed and added to the end I.e. the abc company will end up Abc Company, The.
I then need to check if the name exists in the folder, if it does I need to let the user know and stop. If it doesn’t exist then I can continue and create the folder.
Finally, I need to create a unique customer code which takes the first 4 characters of the name and adds a number I.e. 01. If that 4 digit code already exists then I need to increase the number by +1.
i.e the abc company will end up Abc Company, The (ABCC01)
Now if the user adds another company called: the abc characters, this would end up ABC Characters, The (ABCC02)
This is because the 4 digit code ABCC will have already existed.
Last but not least, if the final 6 digit code gets to 10 i.e. ABCC10, I won’t need the 0 that has sat in front of the number 1-9
I need a little help getting over the line. Here’s what I have so far Shortcuts
The issues are, if there is no folder in the main folder, it won’t work and an error comes up. I have created an alert to show this for the moment. Now if the main folder has 1 folder in it, I get an error. If the main folder has 2 folders in it it works. I’ve not even begun trying to match the name or code yet.