This is a description of the linux rename utility.
If using regular expressions for editing batches of filenames is a feature you could use, then you can download the Perl rename script as a separate package from GitHub:
$ wget https://github.com/subogero/rename/archive/master.zip
$ unzip master.zip
$ cd rename-master
Assuming you have a $HOME/bin directory near the start of your $PATH:
$ cp rename ~/bin/.
Then when you do:
$ which rename
you should see ~/bin/rename which is the Perl rename script.
*** NOTE: Before you start editing large batches of filenames, use rename with the -n flag. Running rename with -n will show you how your files will be renamed without actually making any changes (i.e. causing any headaches). If the results are what you wanted, then re-run rename without the -n flag to make the filename changes. ***
Examples
You can rename filenames by inserting a new field of information such as DATE like this:
$ ls
water_site1_CO1_sample1.fastq.gz
water_site1_CO1_sample2.fastq.gz
water_site1_CO1_sample3.fastq.gz
$ rename 's/\.fastq/_20180101\.fastq/g' *.fastq.gz
$ ls
water_site1_CO1_sample1_20180101.fastq.gz
water_site1_CO1_sample2_20180101.fastq.gz
water_site1_CO1_sample3_20180101.fastq.gz
You can shuffle fields using groups, wildcards, and repetitions:
$ rename 's/water_site1(_CO1)(_sample\d{1})(_20180101)/water_site1$3$2$1/g' *.fastq.gz
$ ls
water_site1_20180101_sample1_CO1.fastq.gz
water_site1_20180101_sample2_CO1.fastq.gz
water_site1_20180101_sample3_CO1.fastq.gz
You can use character classes:
$ rename 's/sample[0-9]_/sample0[0-9]_/g' *.fastq.gz
$ ls
water_site1_20180101_sample01_CO1.fastq.gz
water_site1_20180101_sample02_CO1.fastq.gz
water_site1_20180101_sample03_CO1.fastq.gz
Or you can just correct punctuation like changing underscores to dashes:
$ rename 's/_/-/g' *.fastq.gz
$ ls
water-site1-20180101-sample01-CO1.fastq.gz
water-site1-20180101-sample02-CO1.fastq.gz
water-site1-20180101-sample03-CO1.fastq.gz
For more information on Perl regular expressions (see Perl regular expressions).