Find and replace filename recursively in a directory

前端 未结 14 1991
野趣味
野趣味 2020-11-28 21:24

I want to rename all the files in a folder which starts with 123_xxx.txt to xxx.txt.

For example, my directory has:

123_xxx         


        
14条回答
  •  萌比男神i
    2020-11-28 22:03

    using the examples above, i used this to replace part of the file name... this was used to rename various data files in a directory, due to a vendor changing names.

    find . -name 'o3_cloudmed_*.*' -type f -exec bash -c 'mv "$1" "${1/cloudmed/revint}"' -- {} \;

提交回复
热议问题