How to rename many files at once?
Author: S.Luyssaert
Last revision: 2020/03/19, J. Lathière
There are several reasons why you suddenly have the need to change the name of tens if not hundreds of files at once. The mv command in unix seems a bit limited in its scope so here are two more options.
RENAME
To rename lists of files use the rename command in unix
rename [string to replace] [string to replace it with] [files for which you want to replace the string]
SHELL SCRIPT
Write a little shell script
#!/bin/bash echo "rename the files..." for file in *.nc do echo "Rename $file ." # mv -i "${file}" "${file/cru_nicolasgrid_/cmip5_ipsl_rcp4p5_}" mv -i "${file}" "${file/cmip5_ipsl_rcp4p5/ipsl_rcp4p5}" done
Last modified 5 years ago
Last modified on 2020-03-19T16:01:31+01:00