TransWikia.com

linux command line subfolder files batch rename that actually works

Stack Overflow Asked by fika_fika on September 18, 2020

In a folder with many subfolders, each containing mp4 files with names ending in foobar.mp4

How can I get rid of the suffix? I have tried:
find ./*/*.mp4 -type f -exec rename 's/foobar//' '{}' ;

One Answer

On surface, there is no need to use 'find', as the rename command has the ability to process list of file. In particular, possible to write

rename 's/foobar//' */*foobar.mp4

It's not clear from the OP what are the actual file names. The above command will rename 'foobar.mp4' to hidden file '.mp4', and the file 'x.foobar.mp4' to 'x..mp4'.

Answered by dash-o on September 18, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP