Score:1

Is there a renaming tool (for Ubuntu 18.04 Mate) which is able to work on folder names as well?

in flag

I am rather new to Linux, I am using Ubuntu 18.04 Mate. When I need to do more complex file renaming tasks I prefer to use KRename (the GUI version that got installed with apt-get). But often I'd also like to rename folders' names (this question is NOT about batch renaming of file names). It seems KRename (GUI) is not capable of doing that. So I wonder whether there's a tool to achieve that (as a beginner I prefer not to write scripts).

sancho.s ReinstateMonicaCellio avatar
pl flag
https://www.makeuseof.com/batch-rename-files-in-linux/
sancho.s ReinstateMonicaCellio avatar
pl flag
Or `thunar -B`. See also https://ostechnix.com/how-to-rename-multiple-files-at-once-in-linux/
guiverc avatar
cn flag
I'd use a terminal and just use `mv` (usually easier than `rename` but I may use that too for some). You've not given many details; ie. what OS, release & desktop you're using; mention of `krename` makes me think of KDE so where you have multiple GUI choices as well - but you've not said why those aren't usable to you (ie. `dolphin` etc).
Shakesbeer avatar
in flag
@guiverc: I edited the question to give more details. I am using Ubuntu 18.04 Mate. I'm a beginner, it's easier for me and faster to use a GUI than to write a script or use the command line when I have to rename dozens of files (and folders). As a beginner I also have limited knowledge of alternatives, I do not even know whether there are different GUIs to KRename.
muru avatar
us flag
"I have to rename dozens of files (and folders)" ... that is called "batch renaming"
Shakesbeer avatar
in flag
@muru: the question is not about **files**, it's about **folders**. That's the point.
muru avatar
us flag
@Shakesbeer For renaming, there's no difference. *That's* the point.
Shakesbeer avatar
in flag
@muru: That may be true for the command line but not for KRename GUI: when I add a folder, how can I get it to process the folder's name instead of adding the folder's content (the names of the files in it) to the list of objects to rename?
guiverc avatar
cn flag
https://en.wikipedia.org/wiki/Everything_is_a_file (a basic theory from 1970 in unix, that applies in modern day GNU/Linux just as it did back then) Also note Ubuntu-MATE being a *flavor* of Ubuntu, came with 3 years of life, which ended April-2021; see https://ubuntu-mate.community/t/ubuntu-mate-18-04-lts-reaches-end-of-life/23966
Shakesbeer avatar
in flag
@guiverc: I didn't ask for a theoretical introduction to the way that information is organized on a file system or whatever. As long as - in this case - KRename GUI does not treat files and folders identically, there IS a difference. And that difference leads to my question.
guiverc avatar
cn flag
You can use `caja` which comes with Ubuntu-MATE, and will use less resources (as it shares libraries/toolkits with your desktop unlike `krename`). If you're online, don't forget to use `ubuntu-support-status` to decide for yourself the risks of using a EOL OS (parts of your system in common with Ubuntu Desktop 18.04 LTS are still supported; MATE, `krunner` etc are not)
muru avatar
us flag
@Shakesbeer https://www.kubuntuforums.net/showthread.php/72944-Krename-Renaming-Folders?p=409594&viewfull=1#post409594?
sancho.s ReinstateMonicaCellio avatar
pl flag
Did you find anything of what was posted useful? It is always good to provide feedback.
Shakesbeer avatar
in flag
I will do some tests and report the results as soon as I find the time, please be patient.
sancho.s ReinstateMonicaCellio avatar
pl flag
... any feedback?
Score:0
jp flag

rename can rename both files and directories

A command line tool is suitable for this kind of task. I can show how it works with an example:

Make two test directories

$ mkdir rentest1
$ mkdir rentest2

Make a test file

$ touch rentest3

Check that rename does what you expect with a 'dry run' using the option -n

$ rename -n 's/ren/rename-/' rentest*
rename(rentest1, rename-test1)
rename(rentest2, rename-test2)
rename(rentest3, rename-test3)

When it looks good, remove -n and do it

$ rename 's/ren/rename-/' rentest*

Check that it worked for both the file and the directories

$ ls -ld rename*
drwxrwxr-x 2 sudodus sudodus 4096 aug 11 13:47 rename-test1
drwxrwxr-x 2 sudodus sudodus 4096 aug 11 13:47 rename-test2
-rw-rw-r-- 1 sudodus sudodus    0 aug 11 13:48 rename-test3

Learn about all the features in

man rename

My version of rename is installed via the package rename from the repository universe, and it is a Perl script by Larry Wall.

Score:0
pl flag

There are quite a few options, both via command line or GUI. Which one suits your needs may depend on the patterns you want to use for renaming.

I am only citing explicitly here one GUI option (since you used KRename), which is thunar -B

enter image description here

You could check other alternatives in sources below.

if using CLI, you could always "wrap" your command with for d in $(find . -type d <other options>) ; do <your operations on "${d}", including renaming> ; done.

Sources:

  1. https://www.makeuseof.com/batch-rename-files-in-linux/
  2. https://ostechnix.com/how-to-rename-multiple-files-at-once-in-linux/
raj avatar
cn flag
raj
Using a `for` loop like you suggested is discouraged. Rather `-exec` option to `find` should be used: `find . -type d <other options> -exec <your operations on {}> \;`
sancho.s ReinstateMonicaCellio avatar
pl flag
@raj - I actually use a lot your suggestion. But what is posted works fine in many cases. https://stackoverflow.com/a/9612232/2707864 provides further info. If you could add the reasons why/the cases when `for ... $(find ...)` is discouraged, that will help a lot.
raj avatar
cn flag
raj
It will cause trouble when directory names contain spaces or other characters that could be interpreted as separators by `for`.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.