File rename hierarchical with RegEx help
Posted: Sun Sep 10, 2017 12:22 am
Dear clever heads;
As this is my first post, I would like to say hello in the first place.
I am trying to sort out file renaming with RegEx, but as I am a novice on this, it is not so straightforward as one would have thought, therefore I dare to ask for help in here.
Files need to be renamed with a hierarchical format
01.01_Filename.ex
02.01_Filename.ext (...)
10.01_Filename.ext
10.10_Filename.ext
Initial filenames are the whole variety of options, starting from:
01. filename.ext
1 file name.ext
1.1. filename.ext
5.13 filename.ext
etc.
to some more sophisticated ie:
Section 1 filename.ext
Is it possible for a Regular Expression to search the first say 5 characters in a file name (only digits, excluding letters) for single digits and if they are single, add 0 before, but if they are double digits skip them, while if there is no digit after the dot (ie. 01 filename.ext) - add 00 or whatever is required to match the input mask??
The 'filename' part is to be intact, so in essence it is only about the hierarchy numbering at the beginning of the file name.
If anything is not clear enough in this brief explanation, by all means please ask.
Thank you in advance.
As this is my first post, I would like to say hello in the first place.
I am trying to sort out file renaming with RegEx, but as I am a novice on this, it is not so straightforward as one would have thought, therefore I dare to ask for help in here.
Files need to be renamed with a hierarchical format
01.01_Filename.ex
02.01_Filename.ext (...)
10.01_Filename.ext
10.10_Filename.ext
Initial filenames are the whole variety of options, starting from:
01. filename.ext
1 file name.ext
1.1. filename.ext
5.13 filename.ext
etc.
to some more sophisticated ie:
Section 1 filename.ext
Is it possible for a Regular Expression to search the first say 5 characters in a file name (only digits, excluding letters) for single digits and if they are single, add 0 before, but if they are double digits skip them, while if there is no digit after the dot (ie. 01 filename.ext) - add 00 or whatever is required to match the input mask??
The 'filename' part is to be intact, so in essence it is only about the hierarchy numbering at the beginning of the file name.
If anything is not clear enough in this brief explanation, by all means please ask.
Thank you in advance.