User Tools

Site Tools


bash:rename_multiple_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
bash:rename_multiple_files [2016/11/11 09:56] – created peterbash:rename_multiple_files [2021/01/26 12:30] (current) – removed peter
Line 1: Line 1:
-====== Bash - Rename multiple files ====== 
- 
-The **rename** command which is part of the Perl installation helps.  All you need to know is the basics of regular expressions to define how the renaming should happen. 
- 
-To add a '.old' to every file in your current directory.  At the end of each expression ($) a '.old' will be set: 
- 
-<code bash> 
-rename 's/$/.old' * 
-</code> 
- 
- 
-To make the filenames lowercase: 
- 
-<code bash> 
-rename 'tr/A-Z/a-z/' * 
-</code> 
- 
- 
-To remove all double characters: 
- 
-<code bash> 
-rename 'tr/a-zA-Z//s' * 
-</code> 
- 
- 
-You have many JPEG files that look like “img0000154.jpg” but you want the first five zeros removed as you don’t need them: 
- 
-<code bash> 
-rename 's/img00000/img/' *.jpg 
-</code> 
- 
- 
-In fact you can use any Perl operator as an argument.  The actual documentation for the 's' and 'y'/'tr' operators are found in the 'perlop' manpage. 
  
bash/rename_multiple_files.1478858168.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki