Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

change the first character in file name

New Here ,
Dec 09, 2024 Dec 09, 2024

Hey folks.

I have big data base with specific file names.

Example

w=xxx-sometext-sometext-sometext-sometext_.tif

w=xxxxxx-sometext-sometext-sometext-sometext_.tif

Numbers of x are different. I want to only change the first - to _ like below

w=xxx_sometext-sometext-sometext-sometext_.tif

 

How to do this?

 

 

TOPICS
Batch
314
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 09, 2024 Dec 09, 2024

Assuming the file names only have numbers at the beginning, you can use this regex to match only the dash after a number:

(?<=\d\d)-

 You can use this in the batch rename tool with the string substitution option and the "use regular expression" box checked.

9yz_0-1733778274047.png

If your filenames can also have numbers in the middle and you don't want to replace the dashes after those, it's a bit more complicated because in Regex, lookbehinds (something that looks backwards in the string without selecting those characters) need to have a fixed length. So, you're going to need multiple instances of this string substitution, each with a different number of "\d"s in them - these match individual digits.

// matches only a dash that comes after the start of the string followed by 1 digit
(?<=\A\d)-
// matches only a dash that comes after the start of the string followed by 2 digits
(?<=\A\d\d)-
// matches only a dash that comes after the start of the string followed by 3 digits
(?<=\A\d\d\d)-

// etc...

 Hope this helps!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 10, 2024 Dec 10, 2024
LATEST

@dawidc21191320 

 

As long as you untick the "Replace all" then only the first match will be replaced.

 

2024-12-11_08-42-29.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines