delete random string from filename

English support forum

Moderators: sheep, Hacker, Stefan2, white

Post Reply
terezava
Junior Member
Junior Member
Posts: 3
Joined: 2018-10-08, 10:47 UTC

delete random string from filename

Post by *terezava »

Hi.
I have many files named by this pattern:
randomstring - username.jpg
I would like to delete all strings except a username, so final filename should be username.jpg
Length of both, a random string and username are variable.
How can I do it?
User avatar
Stefan2
Power Member
Power Member
Posts: 3043
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: delete random string from filename

Post by *Stefan2 »

Hi and welcome, terezava.
terezava wrote:
2018-10-08, 11:01 UTC
How can I do it?
You have to find a common marker (anchor) on your file names,
like "first space" or "second hyphen" or "last comma",
or "delete first 10 signs" or "keep last 20 signs" or use signs "S"+two digits as anchor.



 
 
terezava
Junior Member
Junior Member
Posts: 3
Joined: 2018-10-08, 10:47 UTC

Re: delete random string from filename

Post by *terezava »

Thank you Stefan2 :-)
The dash is common marker. I would like to leave all behind the dash. But I don't know how to do it. I tried Multi-Rename Tool, but I am not able transform such request into the regular expression.
User avatar
Stefan2
Power Member
Power Member
Posts: 3043
Joined: 2007-09-13, 22:20 UTC
Location: Europa

Re: delete random string from filename

Post by *Stefan2 »

FROM:
randomst - username 2.jpg
random string - user name.jpg
randomstring - username.jpg
randomstring 3 - user.jpg

TO:
user.jpg
user name.jpg
username.jpg
username 2.jpg

RULE:
remove everything till (single or last occurrence of) SpaceHyphenSpace


MRT:
Search: .+-#
Replace:
[x]RegEx


# is here a marker for an space: ".+- "


 
terezava
Junior Member
Junior Member
Posts: 3
Joined: 2018-10-08, 10:47 UTC

Re: delete random string from filename

Post by *terezava »

I got it! Thank you very much :-)
Post Reply