Score:2

Rename some files to their own name + something else

br flag

I have a directory like Photo

Directory Picture!

and I want to change the names of the directories inside it -> to what they are, but without it [www.faraDa...] like the first one that I change by mv command. but I dont know how remove [www.faraD...] automatically ? can do this by find ... -exec or mv in linux command or I need programing like python? to do it.

Update : in ubuntu 20.04 LTS

names are : FVLNX9510 Atoz [www.FaraD...‍‍ They have a difference in the middle part of their name A,B,C,D,....

Thank you all !

Someone avatar
my flag
Please [edit] the question and clarify like Ubuntu version and some other details
guiverc avatar
cn flag
I'd suggest using the `rename` command, but I don't understand your wanted name change sorry.
Sir-Sorg avatar
br flag
@Algnis Ok,I add system info in it but its Normal ubuntu.
Score:1
us flag

If the string to change is always the same in all files you could use this command:

rename \[www.website\]  '' *

This command works on Fedora 33 actually (I thought it was the same on Ubuntu), however this answer provides an extensive description on how to use rename on Ubuntu. I think that the command I wrote above should change in something like:

rename 's/\[www\.website\]//' *

Here you can find a description of different rename packages.

bac0n avatar
cn flag
I think most people associate `rename` with Perl `File-Rename` with slightly different syntax. If you could state which rename command you use.
overmach avatar
us flag
You are right, sorry! Let me edit my answer.
Sir-Sorg avatar
br flag
thank,but its different -> its is : `FVLNX9510` **`A`to`z`** `[www.FaraD...‍‍` They have a difference in the middle part of their name - `A B C D E F G ...`
overmach avatar
us flag
@Sir-Sorg ok but if you need to remove the part between brackets [...] the command I posted above should do the work.
Sir-Sorg avatar
br flag
@overmach OK,I test it.but can do this by function of bash?
bac0n avatar
cn flag
`for i in *; do mv "${i}" "${i::11}"; done`
bac0n avatar
cn flag
@Sir-Sorg `mmv 'FVLNX9510 ? *' 'FVLNX9510 #1'` but I would still use `mmv` for this.
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.