Home »
Digital Archaeology »
Digital Archaeology »
Batch rename files in Linux
Batch rename files in Linux [message #374859] |
Fri, 19 October 2018 17:20 |
CyberkNight
Messages: 1606 Registered: July 2012
Karma: 0
|
Senior Member |
|
|
Occasionally you will, for one reason or another, have a bunch of files that have filenames with a special character or some character that is giving you a problem for some reason. For instance, i had a bunch of image files named like "image #1.jpg" but the '#' character caused problems in the web based gallery program I was using. There are a million ways to batch rename files in Linux but the command 'mmv' offers a very simple method. I wanted to replace the ' #' with an '_' so the command was:
mmv "image #*" "image_#1"
The '#1' in the second parameter is expanded with whatever the wildcard ('*') gives you from the first. You can use multiple wildcards. For example:
mmv -c "report*part*.txt" "./french/rapport#1partie#2.txt"
Use the '-n' switch to preview your changes so that you know you constructed your command correctly.
For more info, see the man entry for mmv.
Megalextoria
[Updated on: Fri, 19 October 2018 17:21] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Fri Mar 29 03:37:56 EDT 2024
Total time taken to generate the page: 0.03666 seconds