Rearrange file name parts
Greetings - using this forum, I've been able to answer a lot of my questions, but I'm stumped on this one. I have a bunch of file names in the following format:
word1 word2 word3-yyyy-mm-dd.ext
I would like to move the yyyy-mm-dd in between word2 and word3, adding "--" so that it looks like this:
word1 word2 yyyy-mm-dd--word3.ext
I've played around with the \w expression, but can't seem to get it right. Can someone kindly help?
Thanks,
Dataguy
word1 word2 word3-yyyy-mm-dd.ext
I would like to move the yyyy-mm-dd in between word2 and word3, adding "--" so that it looks like this:
word1 word2 yyyy-mm-dd--word3.ext
I've played around with the \w expression, but can't seem to get it right. Can someone kindly help?
Thanks,
Dataguy
Reply to #1:
Hi Dataguy,
Based on the limited example there are many ways to do what you want. Here are a few. They all require using one replace method with regular expressions checked.
(1)
Replace: (<word:1>) (<word:2>) (<word:3>)-(.*)
Replace with: $1 $2 $4--$3
(2)
R: <word:1> <word:2> <word:3>-(.*)
Rw: <word:1> <word:2> $1--<word:3>
(3)
R: (\w+) (\w+) (\w+)-(\d{4}-\d{2}-\d{2})
Rw: $1 $2 $4--$3
(4)
R: ([^ ]+) ([^ ]+) ([^-]+)-(.*)
Rw: $1 $2 $4--$3
(No spaces before or after the expressions, just inside them)
There's one more way I thought of, that doesn't use regular expressions:
R: <word:3>-<word:4>-<word:5>-<word:6>
Rw: <word:4>-<word:5>-<word:6>--<word:3>
Just in case you are regex-shy... :)
Let us know how these work out for you.
Best
DF
Hi Dataguy,
Based on the limited example there are many ways to do what you want. Here are a few. They all require using one replace method with regular expressions checked.
(1)
Replace: (<word:1>) (<word:2>) (<word:3>)-(.*)
Replace with: $1 $2 $4--$3
(2)
R: <word:1> <word:2> <word:3>-(.*)
Rw: <word:1> <word:2> $1--<word:3>
(3)
R: (\w+) (\w+) (\w+)-(\d{4}-\d{2}-\d{2})
Rw: $1 $2 $4--$3
(4)
R: ([^ ]+) ([^ ]+) ([^-]+)-(.*)
Rw: $1 $2 $4--$3
(No spaces before or after the expressions, just inside them)
There's one more way I thought of, that doesn't use regular expressions:
R: <word:3>-<word:4>-<word:5>-<word:6>
Rw: <word:4>-<word:5>-<word:6>--<word:3>
Just in case you are regex-shy... :)
Let us know how these work out for you.
Best
DF