Change file extensions
rename oldFileextension newFileextension FilesToRename Examples rename all .csv files into .txt files rename .csv .txt *.csv rename .fasta files into .fna files
change all sampleID.fasta into sampleID.fna
rename .fasta .fna *.fasta add species name (e.g., E.coli) to all .bam files change all sampleID.bam files into sampleID_ecoli.bam rename .bam _ecoli.bam *.bam error: syntax error at (eval 1) line 1, near "." error: syntax error at (user-supplied code), near "." getting these errors, means you have another rename command (Ubuntu) which uses Perl regular expressions: Ubuntu: rename all .csv files into .txt files (same as above, but using the "Perl" based rename)
rename 's/\.csv$/.txt/' *.csv general: renaming a string at any position in filename (Example: change all 'dataNew' into 'data2015')
rename 's/dataNew/data2015/' *.csv Add prefixchange prefix of all textfilesrename 's/^oldPrefix/newPrefic/' *. txt (Perl based rename version - Ubuntu)add project name to all .bam files change all sampleID.bam files into projectABC_sampleID.bam
rename 's/^/projectABC_/' * .bam (Perl based rename version - Ubuntu)if it does not work (non-Perl rename command), use a shell loop:
for f in *.bam ; do mv "$f" "projectABC_$f" ; done # add suffix ".txt" to all files in a folder for FILE in *; do mv ${FILE} ${FILE}.txt; done |
Tools > Ubuntu/Linux server >