Recursivly rename folders removing characters as required

HI guys here's hoping some on pout the can help

I have a large library of epub and mobi file creates some what by calibre.

Output of tree listing below

I would like to recursively rename the directories removing the brackets and numbers

I have been scratching my head over this one all day so any help would be gratefully appreciated

Any attempts beyond scatching your head?

yeah although i got a few splinters from the scratching

I can accomplish this fine with a line of text ie

give me the output i would like to rename to but how to apply this recursively to all directories is currently evading me

Try

find . -type d -name "*([0-9]*)" | while read FN; do echo mv $FN ${FN%([0-9]*)}; done

This doesn't check for three digits but allows for anything after the first digit; this may need some refinement. If the results comes close to what you need, remove the echo for real action.

1 Like

Thanks for the heads up had to add some inverted commas due to spaces in the names so

worked a treat :slight_smile: