Change the name of a file
I want to understand how to change the name of a file with the terminal and a Mac. I have been searching and I found many solutions. For example here: Using sed to mass rename files
This changes a file from F00001-070
to F000-070
.
for file in *.txt; do echo mv -v "$file" "${file/#F0000/F000}"; done
I have tested and it works well. But now I try to change that
from old-file.txt
to new-file.txt
for file in *.txt; do echo mv -v "$file" "${file/#old/new}”; done
That last one does not work.
I thought that file/#F0000/F000
mean change files beginning F0000 to F000. I must be wrong?
Can someone explain the code and apply to how to change part of the name of a file at the begin, end or in the middle