Rename script needed
Rename script needed
Hello,
I had a great experience with a script that jacky gave me. Scripting is certainly a powerful thing so I'm wondering if it can do a little something I'm after.
Basically, I have a list of files. They have same names at the beginning with incrementing and same names at the end (incl extensions). However, stuff in the middle is different and i'd like to trim the list down by getting rid of that stuff in the middle.
Example:
abc.01.def.ghi.extension
abc.02.jkl.ghi.extension
abc.03.mno.ghi.extension
and so on...
What I'm after is a script that would go through the list of files and remove the def/jkl/mno/... parts while retaining the rest. I know something like this could be tricky so thank you very much in advance. If something isn't clear then please ask here or PM me, thanks again
I had a great experience with a script that jacky gave me. Scripting is certainly a powerful thing so I'm wondering if it can do a little something I'm after.
Basically, I have a list of files. They have same names at the beginning with incrementing and same names at the end (incl extensions). However, stuff in the middle is different and i'd like to trim the list down by getting rid of that stuff in the middle.
Example:
abc.01.def.ghi.extension
abc.02.jkl.ghi.extension
abc.03.mno.ghi.extension
and so on...
What I'm after is a script that would go through the list of files and remove the def/jkl/mno/... parts while retaining the rest. I know something like this could be tricky so thank you very much in advance. If something isn't clear then please ask here or PM me, thanks again
hmm.. not sure if that's possible just based on parts the are the same or not, but if it's always the same structure, for example the names are always somtehing + dot + numbers + dot + something you want out + dot + something + dot + extension, then I guess it could be done.
Although, no script required here, just a RegExp Rename job. Something like this should do it:
Although, no script required here, just a RegExp Rename job. Something like this should do it:
Code: Select all
^(.+\.[0-9]+\.).*\.([^.]+?\.[^.]+?)$>$1$2
Proud XYplorer Fanatic
Using your analogy what I'm after is this:
samething1.mixture of numbers and letters (numbers incrementing).always different.samething1.extension
needs to become this:
samething2.mixture of numbers and letters (numbers incrementing.samething2.extension
I hope it's clearer And how is such RegExp Rename job applied? Thanks
samething1.mixture of numbers and letters (numbers incrementing).always different.samething1.extension
needs to become this:
samething2.mixture of numbers and letters (numbers incrementing.samething2.extension
I hope it's clearer And how is such RegExp Rename job applied? Thanks
-
- XY Blog Master
- Posts: 5824
- Joined: 02 Jan 2006 19:34
- Location: So. Chatham MA/Clearwater FL
- Contact:
It's executed by selecting the files, and then using File | Rename Special | RegExp Rename.ivan wrote:I hope it's clearer And how is such RegExp Rename job applied? Thanks
jacky's concern was about the consistency of the format of the file name before and after...basically, is there some fixed length of the parts between the "." or does it vary, and are there varying numbers of "." in the names, as those separators and/or lengths can be used to isolate the parts to be modified.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
Here is some more info:
1. The format the files are in is as follows part1.part2.part3.part4.extension
where
part 1 = various words (sometimes just one, no numbers) separated by varying number of dots. No spaces between dots and/or words.
part 2 = is always 6 symbols long with mixture of letters and numbers. the numbers at the end increment by one going down the list
part 3 = always varies in terms of words, numbers, symbols and dots separating them. still no spaces between them.
part 4 = virtually always a mixture of letters, symbols and dots. numbers are rare so if they're present i can rename manually. but for each set of files that need to be renamed those letters, symbols and dots are always in the same sequence.
Part 3 is the one that needs to be removed
Of course, the cases of letters need to be preserved during renaming
Cheers for the help!
1. The format the files are in is as follows part1.part2.part3.part4.extension
where
part 1 = various words (sometimes just one, no numbers) separated by varying number of dots. No spaces between dots and/or words.
part 2 = is always 6 symbols long with mixture of letters and numbers. the numbers at the end increment by one going down the list
part 3 = always varies in terms of words, numbers, symbols and dots separating them. still no spaces between them.
part 4 = virtually always a mixture of letters, symbols and dots. numbers are rare so if they're present i can rename manually. but for each set of files that need to be renamed those letters, symbols and dots are always in the same sequence.
Part 3 is the one that needs to be removed
Of course, the cases of letters need to be preserved during renaming
Cheers for the help!
tried to get something to work.
but since the number of characters varies and there are dots in the middle of the parts, i can't think of a way to separate the parts in the regex.
if you are willing to count the dots after part3 then this MIGHT work.
i'm not an expert when it comes to regex, so try it with the preview.
just put replace 'dots' with the number you got.
say, if part4 is 'asd.fgh.jkl' in the file
part1.part2.part3.asd.fgh.jkl.extension
4 dots
but since the number of characters varies and there are dots in the middle of the parts, i can't think of a way to separate the parts in the regex.
if you are willing to count the dots after part3 then this MIGHT work.
i'm not an expert when it comes to regex, so try it with the preview.
just put replace 'dots' with the number you got.
Code: Select all
([A-Za-z.]+)([A-Za-z0-9]{6}).+((\..+){dots})>$1$2$3
part1.part2.part3.asd.fgh.jkl.extension
4 dots
the problem here is to find where part3 ends and part4 begins.
if the dash was always in the first part of part4 i could use it to mark where the regex must stop deleting.
this is how i made it find where part3 starts, since numbers always appear in part2, but never in part1.
dashes won't be a problem.
but numbers in part1 will mess up everything.
and part2 must not have more than 6 chars.
this regex ignores part2's lenght.
remember to test it.
never trust a regex.
if the dash was always in the first part of part4 i could use it to mark where the regex must stop deleting.
this is how i made it find where part3 starts, since numbers always appear in part2, but never in part1.
dashes won't be a problem.
but numbers in part1 will mess up everything.
and part2 must not have more than 6 chars.
this regex ignores part2's lenght.
Code: Select all
([A-Za-z.]+)([A-Za-z0-9]+)\..+((\..+){dots})>$1$2$3
never trust a regex.
-
- XY Blog Master
- Posts: 5824
- Joined: 02 Jan 2006 19:34
- Location: So. Chatham MA/Clearwater FL
- Contact:
And in some cases, I've had to do it in multiple passes, using slightly different renames (plus a bit of manual editing) to get the final results...
The inconsistency in format is what is the problem, so if you can get it more standardized, you may have better luck!
The inconsistency in format is what is the problem, so if you can get it more standardized, you may have better luck!
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.