2

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 !

Sir-Sorg
  • 53
  • 5

1 Answers1

1

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.

overmach
  • 11
  • 3
  • 1
    I think most people associate `rename` with Perl `File-Rename` with slightly different syntax. If you could state which rename command you use. –  Nov 13 '21 at 10:58
  • You are right, sorry! Let me edit my answer. – overmach Nov 13 '21 at 11:03
  • 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 ...` – Sir-Sorg Nov 13 '21 at 15:49
  • @Sir-Sorg ok but if you need to remove the part between brackets [...] the command I posted above should do the work. – overmach Nov 14 '21 at 09:55
  • @overmach OK,I test it.but can do this by function of bash? – Sir-Sorg Nov 14 '21 at 11:46
  • `for i in *; do mv "${i}" "${i::11}"; done` –  Nov 14 '21 at 12:38
  • @Sir-Sorg `mmv 'FVLNX9510 ? *' 'FVLNX9510 #1'` but I would still use `mmv` for this. –  Nov 14 '21 at 12:40