Simple rename of file using part of the string

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
mumajs
Posts: 57
Joined: 03 Nov 2018 16:47

Simple rename of file using part of the string

Post by mumajs »

Guys,

last few days I had to work on one project and I had tu reuse files already procesed by 3rd part of program. I needed very quickly to rename files from format like FIRSTNAME.LASTNAME.119399697_INPROGRESS_DHM PICKLIST REPORT20191024_100516.txt and remove everything after _ so the filename is FIRSTNAME.LASTNAME.119399697.txt and it was HUGE PAIN for me. I did not find the way in XYPLORER how to do that for 100+ files and I was lost. I had to use another file manager which has pretty clear renaming feature to use just substring or so....
Using regexp is something not so cool because I am not regexp guy... I can create regexp expresion myself for repeatedly used task, but not when I am under presure and need to do a task now. I recognize that in that topic xyplorer absolutely unusable.
When this type of task will be necessary again then how to accomplish that faster and without stress?

Thank you

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Simple rename of file using part of the string

Post by highend »

Sorry to disappoint you, but (in XY) this is a regexp rename...

(.+?)(_.*?)(\.[a-z0-9]{2,4})$ > $1$3
$1$3 are the references to the first (everything before the first underscore)
and the last (the extension) parts...

or a lot easier but only if you have the same file extension for all files (in this example .txt):
_.* > .txt
One of my scripts helped you out? Please donate via Paypal

mumajs
Posts: 57
Joined: 03 Nov 2018 16:47

Re: Simple rename of file using part of the string

Post by mumajs »

Highend,

I thank you a lot. Your both proposals works wonderful. Even the simple one for the same extension. You are really valued memeber of the comunity and I really appreciate your help! I'm not disappointed, I was just under stress and didn't know what to do and in that time it was not easy to find any of your ways. Seems I should spend more time on regexp and then I will be more familiar and these situations will not kill me. I like xyplorer a lot and I am happy that comunity members like you are here!

highend
Posts: 13317
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Simple rename of file using part of the string

Post by highend »

To make things a bit easier for these kind of renames: viewtopic.php?f=7&t=21068
One of my scripts helped you out? Please donate via Paypal

mumajs
Posts: 57
Joined: 03 Nov 2018 16:47

Re: Simple rename of file using part of the string

Post by mumajs »

that is absolutely awsome. Very good work highend! It works as a charm!

Dustydog
Posts: 321
Joined: 13 Jun 2016 04:19

Re: Simple rename of file using part of the string

Post by Dustydog »

Some other things that might be useful to you (regular expression and renaming resources):

If you don't know how to use regular expressions, you might want to read these (my favorite tutorial sites):
https://www.regular-expressions.info/
Take particular note of this page there as it describes the "flavor" of regular expression engine used in XY:
https://www.regular-expressions.info/vb.html

Then there's also this, which explains a few subjects a little more clearly than the above. Each will obviously have places where they're more clear, but if you were to choose one, choose the top. He's arguably the world expert on the subject, and he's given an incredible amount of information for free. For a slight fee, you can even download the guide as a .pdf or see it online without its (very reasonable) ads.
https://www.rexegg.com/

There are also several online regular expression test sites. Here's one that seems useful, recommended by Rexegg:
https://regex101.com/r/tP9zZ6/1

The very best tool (paid) that you can get is RegexBuddy written by Jan Goyvaerts, the programmer who supplied the tutorial listed at the top. It's worth every cent. I constantly use regular expressions with XY. Regular expressions are a hugely useful tool if you take the time to learn them. It's one of the best things I've learned in the past few years related to computing. Even simple regexes are incredibly handy - and not too hard to learn at all - especially with RegexBuddy's help.
https://www.regexbuddy.com/

Finally, if you want a powerful tool (certainly not more powerful than XY, but if you need some help with renaming files and you don't want to mess with regular expressions) is bulk rename utility - which also supports regular expressions - sometimes referred to simply as BRU. It's free, safe (last I looked), and very useful. I used it a lot before I discovered XY. (They make their money off other software. This attracts customers. So you don't need to look too hard for sneaky ways they may be trying to make money. But, check it like you should anything.) It has quite a busy, rather retro interface, but it's because it's powerful. Don't let the interface throw you off, it's actually quite simple once you get used to it. Via its interface, it can do some things that usually only a regex or scripting could do:
https://www.bulkrenameutility.co.uk/

If you need help with something, feel free to PM me. I don't check the forums as often as I should (I tend to binge), but I'm happy to help one on one if you wish. Highend, of course, knows the forum backwards and forwards and is extremely skillful, and as a mod, checks most posts very quickly.

Post Reply