Here’re my source files.
JavaScript
x
e2f9eb91-645f-408a-9241-66490b61a617_file-module-1.txt
d20f06a8-4de1-4da0-8175-93e9b2d81c42_file-module-2.txt
6740a19f-e1a0-43da-9a01-9e873238360e_file-module-3.txt
.
.
.
I need to figure it out a way to rename all the files to remove the first 36 characters up to _file or replacing as something else. I am expecting all the files are as below.
JavaScript
_file-module-1.txt or Yong_file-module-1.txt
_file-module-2.txt or Yong_file-module-2.txt
_file-module-3.txt or Yong_file-module-3.txt
.
.
.
Thanks in advance!
Advertisement
Answer
You can use rename
like this:
JavaScript
rename --dry-run 's/.*_file/Yong_file/' *.txt
If you are on macOS, you can install rename
with homebrew:
JavaScript
brew install rename