How to use Dolphin "Rename" or "KRename" to replace string in folder selection

I want to do simple string find and replace with a selection of folders.

“Foo Thing”
“Foo Whatsit”
“Foo This”
“Foo That”

Where I replace "Foo " with “”

There appears to be no way to do this with Dolphin context menu “Rename”.

I installed “KRename” but it added the contents of the folders, not the folders.

Is there any KDE tool that can do this, take my selection of folders and do a search and replace on a string?

I did it with Thunar from Xfce.

KRename has this function, although a little cumbersome. Krename could probably do this better.

Open Krename
Hit the “Find and Replace” in the “Simple Filename” tab (also available on the “Advanced Tab”)
Hit “Add”
In the “Find” field enter whatever you want to find i.e Foo
In the replace field add whatever you want to replace with or leave blank to just remove.
Hit “OK”
Hit “OK” again
Krename will find the text of all files that have “Foo” in them from your selection (Shown in Original column) and a preview of it removed (in the renamed column).
Hit the “Finish” button to confirm and change.

FYI, KDE Frameworks 6.16 will have a file “replace text” mode in the standard rename dialog.

You can see screenshots in the MR.

I made this feature to address precisely your use-case: simple rename directly integrated, as opposed to krename that does everything but it is a separate program less approachable.

2 Likes

so I can’t work out how to make it rename folders.

I use “Advanced rename options” context menu extension to open the folder in KRename and it adds the contents.

can’t rename the folders, just the files.

can it do folders too?

File manipulation is one big area Linux is well behind on. And no, I don’t think Krename can do multiple folders, just files. It’s still very limited in what it can do. Because of this I’m still using Bulk Rename Utility in a Windows VM for the hard stuff. The only thing that comes close is CoreRename (although it’s a little flaky too).

KDE really needs a good renaming tool. Have a look at some of the functions of Bulk Rename Utility. You can insert text at any point, does folder, files and rename any way you can almost think of.

Looks fantastic.

Bulk Rename Utility (not FOSS) is a crazy application https://www.bulkrenameutility.co.uk/assets/img-bru/bru_main1.png https://www.bulkrenameutility.co.uk/assets/img-bru/bru_main2.png in terms of usability. It is not a kitchen sink but an ocean when it comes to renaming.
If that’s the thing that fits your needs (what are you needs??) keep using it.

For simple renames, I want to make the default dialog enough and usable.
For the rest, KDE suggests KRename (it does regex, exif, id3 tag…) but any option Unix/Linux utility can work, including commandline option.
Still while KRename is pretty powerful, it can be improved (like supporting renaming folders), but that depends on the motivation of contributors.

KDE has no “goal” when it comes feature-completeness, we mean to make software for most’s needs and then some.

“Simple by default, powerful when needed*”
*: up to a certain point, within contribution motivation

back on windows I used to use Directory Opus, very powerful and reliable rename, move and copy tools, with simple scripting, great for processing dozens of render passes from 3dsmax into pipelines for compositing.

as you say linux gui misses poweful GUI tools that are accessible by people who can’t write regex or CLI scripts on the fly. last time I used regex was writing perl in 2000 and it damaged my brain. and the last CLI script I copy and pasted started turning my whole /home into lowercase.

if you don’t know it already, szyszka is a pretty nice app for renaming.

1 Like

There’s a trick to rename the containing folder of multiple files in KRename.

Let’s say you want to move

/path/to/files/foo_1/a
/path/to/files/foo_2/b
/path/to/files/foo_3/c

to

/path/to/files/bar_1/a
/path/to/files/bar_2/b
/path/to/files/bar_3/c

What you do is you select a,b and c with Krename, then in the destination tab you select to move them to /path/to/files/, and then in the renaming tab you rename them to [$dirname]/$, and finally with the “find and replace” tool, you can replace all foos with bars. (In your case, bar can be an empty string)

It’s not perfect (you’ll still have to remove the foo-folders, and you need extra steps if the files’ names contain foo), but it does most of the job.

1 Like

Yeah it’s a crazy good tool Bulk Rename Utility. More than I’ll ever use but there’s some handy things like insert at various positions, numbering is very easy.

I was playing around with Thunar lately as well (I installed Linux Mint and playing around with it). Something like the way they do it might be good for KDE. Seems to have a lot of the basics most people would use and very easy. I don’t remember Thunar working too well on KDE when I tried it years ago (yeah I know it’s the defailt FM for XFCE).

As for ID Tags, I rarely use them as a Tag to filename. Mainly because they’re generally wrong (unless I’ve personally updated them). Handy if they are correct though

Well that’s the thing with Linux desktops - in order for it to grow and be adopted by more folk it’s got to become less reliant on scripts, terminal and more GUI. It’s great that Linux still has these features but the average user isn’t interested in those sorts of things. I mean I started out with basic and DOS and used all sorts of systems over the years. I don’t really want to go back to 80’s computers LOL

BTW I’ll check out szyszka. With a silly name like that I wonder if it’s the same guy that wrote the file compare tools czkawka? :joy:

thank you very much, I just tried it and it’s a very good and workable workaround. good stuff.