RegEx challenge: replace dash by space, but not on the date
Moderators: Hacker, petermad, Stefan2, white
-
- Junior Member
- Posts: 4
- Joined: 2024-02-29, 20:19 UTC
RegEx challenge: replace dash by space, but not on the date
Hello,
we have many files in the following format (created by an Adobe software):
WE-TEST-IT-2021-01-13-Test-2019-available.jpg
WE-TEST-IT-2022-01-14-Test-Extensions-Promotion.jpg
WE-TEST-IT-2023-01-15-Test-Extensions-Webinar.jpg
WE-TEST-IT-2024-02-26-Test-added-to-Software-Portfolio.jpg
WE-TEST-IT-2024-02-27-Test-Studio-advancing-resilience.jpg
WE-TEST-IT-2024-02-28-Test-One-2024-1-available.jpg
WE-TEST-IT-2024-02-29-Test-added-to-Software-Portfolio.jpg
I am looking for a RegEx expression for the Multi Rename Tool to replace all dashes by spaces, except for those in the ISO date YYYY-MM-DD within the filenames.
The outcome should then be:
WE TEST IT 2021-01-13 Test 2019 available.jpg
WE TEST IT 2022-01-14 Test Extensions Promotion.jpg
WE TEST IT 2023-01-15 Test ExtensionsWebinar.jpg
WE TEST IT 2024-02-26 Test added to Software Portfolio.jpg
WE TEST IT 2024-02-27 Test Studio advancing resilience.jpg
WE TEST IT 2024-02-28 Test One 2024 1 available.jpg
WE TEST IT 2024-02-29 Test added to Software Portfolio.jpg
The rules are explained in the helpfile with the following limitation:
The used regex library has a limitation that look ahead must be at the end of the regular expression and look behind must be at the start. Otherwise an error will be shown.
I have spent hours trying it and even with Copilot, but it seems that it simply does not work or runs into this error.
Could you please help me finding a RegEx that works in Total Commander, please?
we have many files in the following format (created by an Adobe software):
WE-TEST-IT-2021-01-13-Test-2019-available.jpg
WE-TEST-IT-2022-01-14-Test-Extensions-Promotion.jpg
WE-TEST-IT-2023-01-15-Test-Extensions-Webinar.jpg
WE-TEST-IT-2024-02-26-Test-added-to-Software-Portfolio.jpg
WE-TEST-IT-2024-02-27-Test-Studio-advancing-resilience.jpg
WE-TEST-IT-2024-02-28-Test-One-2024-1-available.jpg
WE-TEST-IT-2024-02-29-Test-added-to-Software-Portfolio.jpg
I am looking for a RegEx expression for the Multi Rename Tool to replace all dashes by spaces, except for those in the ISO date YYYY-MM-DD within the filenames.
The outcome should then be:
WE TEST IT 2021-01-13 Test 2019 available.jpg
WE TEST IT 2022-01-14 Test Extensions Promotion.jpg
WE TEST IT 2023-01-15 Test ExtensionsWebinar.jpg
WE TEST IT 2024-02-26 Test added to Software Portfolio.jpg
WE TEST IT 2024-02-27 Test Studio advancing resilience.jpg
WE TEST IT 2024-02-28 Test One 2024 1 available.jpg
WE TEST IT 2024-02-29 Test added to Software Portfolio.jpg
The rules are explained in the helpfile with the following limitation:
The used regex library has a limitation that look ahead must be at the end of the regular expression and look behind must be at the start. Otherwise an error will be shown.
I have spent hours trying it and even with Copilot, but it seems that it simply does not work or runs into this error.
Could you please help me finding a RegEx that works in Total Commander, please?
Re: RegEx challenge
The following should work although it's a two-step process. No idea if this is possible in a single rename operation.
Search for:
Replace with:(single space character)
Then reload the list via the button with the arrow on it (left of the "Start" button), or press F5.
Search for:
Replace with:
[X] RegEx
Regards
Dalai
Search for:
Code: Select all
-
Code: Select all
Then reload the list via the button with the arrow on it (left of the "Start" button), or press F5.
Search for:
Code: Select all
(.+)(\d{4})\s(\d{2})\s(\d{2})(.+)
Code: Select all
$1$2-$3-$4$5
Regards
Dalai
#101164 Personal licence
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
Ryzen 5 2600, 16 GiB RAM, ASUS Prime X370-A, Win7 x64
Plugins: Services2, Startups, CertificateInfo, SignatureInfo, LineBreakInfo - Download-Mirror
-
- Junior Member
- Posts: 4
- Joined: 2024-02-29, 20:19 UTC
Re: RegEx challenge
Hi Dalai,
thank you very much for your idea with the two steps - that is a nice workaround and highly appreciated if there is not the one-step-solution I was looking for.
thank you very much for your idea with the two steps - that is a nice workaround and highly appreciated if there is not the one-step-solution I was looking for.
Re: RegEx challenge
Code: Select all
Search for: [-(\d\d\d\d-\d\d-\d\d)?]
Replace with: [ $1]
-
- Junior Member
- Posts: 4
- Joined: 2024-02-29, 20:19 UTC
Re: RegEx challenge
Hi white,white wrote: 2024-03-01, 09:41 UTCCode: Select all
Search for: [-(\d\d\d\d-\d\d-\d\d)?] Replace with: [ $1]
thank you for the idea, unfortunately is removes the date and also the other numbers:
WE TEST IT Test available.jpg
WE TEST IT Test Extensions Promotion.jpg
WE TEST IT Test ExtensionsWebinar.jpg
WE TEST IT Test added to Software Portfolio.jpg
WE TEST IT Test Studio advancing resilience.jpg
WE TEST IT Test One available.jpg
WE TEST IT Test added to Software Portfolio.jpg
Re: RegEx challenge
Don't include the outer brackets [ ].CSchneider wrote: 2024-03-01, 20:07 UTC thank you for the idea, unfortunately is removes the date and also the other numbers:
Re: RegEx challenge: replace dash by space, but not on the date
Can be simplified like this:
Search for:
Replace with:
Results:
Image: https://i.imgur.com/ka8CalV.png
Search for:
Code: Select all
-(\d+-\d+-\d+)?
Code: Select all
$1
Image: https://i.imgur.com/ka8CalV.png
#278521 User License
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
Total Commander [always the latest version, including betas] x86/x64 on Win10 x64/Android 10/15
-
- Junior Member
- Posts: 4
- Joined: 2024-02-29, 20:19 UTC
Re: RegEx challenge: replace dash by space, but not on the date
Hi white and beb - thank you very much for your solutions that work both very well. Highly appreciated - you made my day!