Replacing first 4 characters of a filename

Post any Bulk Rename Command support requirements here. Open to all registered users.

Replacing first 4 characters of a filename

Postby AlMo » Sat Dec 24, 2022 6:34 pm

Hi

I have thousands of photos with a file namse which starts with the string "DSCF" eg DSCF0009.jpg to DSCF9999.jpg and I would like to replace the string "DSCF" with the string "XT4A" maintaining the rest of the filename. So as an example "DSCF0009.jpg" would become "XT4A0009.jpg" an so on.

While I am reasonably adept I have never used regular expreessions before and using intuitive approach has not worked for me.

Any help would be gratefully accepted.

Al
AlMo
 
Posts: 2
Joined: Sat Dec 24, 2022 6:21 pm

Re: Replacing first 4 characters of a filename

Postby therube » Mon Dec 26, 2022 6:34 pm

If it's always "DSCF", always a fixed string, then 4:Replace will do it simply.

4:Replace
Code: Select all
Match:  DSCF
With:  XT4A
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Replacing first 4 characters of a filename

Postby therube » Mon Dec 26, 2022 6:42 pm

Heh, oh, we're in BRC...

(I used "2104" & "xxxx", only cause that's what I had on hand, & the x's might be more apparent, but just use your DSCF & XT4A instead.)
Code: Select all
C:\>..\BRC32.exe  /DIR:.   /PATTERN:*.*  /REMOVECHARS:2104 /INSERT:xxxx:0

Processing Folder .\
Filename 210415.053933.BAT would be renamed to xxxx5.53933.BAT
Filename 210415.053933.exe would be renamed to xxxx5.53933.exe
Filename 210415.053933.pdf would be renamed to xxxx5.53933.pdf
Filename 210415.053933_1.pdf would be renamed to xxxx5.53933_.pdf
Filename GO.BAT would be renamed to xxxxGO.BAT
Filename GOGO.BAT would be renamed to xxxxGOGO.BAT

I also set the /PATTERN: as *.*, which then, for your case, would wrongly select files you didn't want, so set to *.jpg.
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Re: Replacing first 4 characters of a filename

Postby AlMo » Sun Jan 29, 2023 7:36 pm

therube wrote:Heh, oh, we're in BRC...

(I used "2104" & "xxxx", only cause that's what I had on hand, & the x's might be more apparent, but just use your DSCF & XT4A instead.)
Code: Select all
C:\>..\BRC32.exe  /DIR:.   /PATTERN:*.*  /REMOVECHARS:2104 /INSERT:xxxx:0

Processing Folder .\
Filename 210415.053933.BAT would be renamed to xxxx5.53933.BAT
Filename 210415.053933.exe would be renamed to xxxx5.53933.exe
Filename 210415.053933.pdf would be renamed to xxxx5.53933.pdf
Filename 210415.053933_1.pdf would be renamed to xxxx5.53933_.pdf
Filename GO.BAT would be renamed to xxxxGO.BAT
Filename GOGO.BAT would be renamed to xxxxGOGO.BAT

I also set the /PATTERN: as *.*, which then, for your case, would wrongly select files you didn't want, so set to *.jpg.
therube wrote:If it's always "DSCF", always a fixed string, then 4:Replace will do it simply.

4:Replace
Code: Select all
Match:  DSCF
With:  XT4A



Thanks. Much appreciated
AlMo
 
Posts: 2
Joined: Sat Dec 24, 2022 6:21 pm


Return to BRC Support


cron