In Linux system, use the following command to implement the requirements:
1. Append the extension (retain the original extension):
find dt\=202* -type f -name 'par*' -exec mv -v -- {} {}.csv \;
Example effects:
→
2. Replace the extension (delete the original extension):
find dt\=202* -type f -name 'par*' -exec sh -c 'mv -v -- "$1" "${1%.*}.csv"' _ {} \;
Example effects:
→
Notes:
dt\=202*
In\
Used for escape=
Symbols to prevent shell parsing errors;The command
-type f
Make sure to process only files;-name 'par*'
Match the file name starting with par;use
-exec
Perform operations on each matching file;It is recommended to pass first
echo
Test command effect:
find dt\=202* -type f -name 'par*' -exec echo mv -- {} {}.csv \;
Remove after confirmationecho
Perform actual modifications.
Summarize
This is the end of this article about several methods for Shell to implement batch renaming files. For more relevant Shell batch renaming files, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!