I have loads of files which look like this:
DET01-ABC-5_50-001.dat ... DET01-ABC-5_50-0025.dat
and I want them to look like this:
DET01-XYZ-5_50-001.dat ... DET01-XYZ-5_50-0025.dat
How can I do this?
Type the following command to rename the part of the file name and press Enter: ren OLD-FILE-NAME-PART*. * NEW-FILENAME-PART*. * In the command, replace "OLD-FILE-NAME-PART" and "NEW-FILENAME-PART" with the old and new parts of the filename.
Alternatively, head to the folder containing the files you want to delete, hit Shift + Right Click, and select Open a command window here. Then input "del [filename]" and press Enter.
Rename Files in Linux using the rename Command. The mv command is a handy tool to rename single files, but if you want to rename multiple files, then you have to use a tool that is specifically made for this. Rename command is used to rename multiple files. This command requires basic knowledge of regular expressions.
There are a couple of variants of a rename command, in your case, it may be as simple as
rename ABC XYZ *.dat
You may have a version which takes a Perl regex;
rename 's/ABC/XYZ/' *.dat
for file in *.dat ; do mv $file ${file//ABC/XYZ} ; done
No rename
or sed
needed. Just bash parameter expansion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With