list of current files “test-file1.txt test-file2.txt test-file3.txt test-file4.txt”
change .txt to .html with rename
rename .txt .html *.txt
new list “test-file1.html test-file2.html test-file3.html test-file4.html”
or use a for loop
for i in *.txt; do mv "$i" "$(basename $i .txt).html"; done OR for i in *.txt; do mv "$i" "`basename $i .txt`.html"; done
Add a prefix to every filename
for f in *.txt ; do mv "$f" "PREFIX_$f" ; done
new list “PREFIX_test-file1.txt PREFIX_test-file2.txt PREFIX_test-file3.txt PREFIX_test-file4.txt”
Add a suffix
for f in *.txt ; do mv "$f" "$f_SUFFIX" ; done
Remove the PREFIX_ from every filename, adjust the cut command accordingly
for name in PREFIX_* ; do newname="$(echo "$name" | cut -b8-)"; mv "$name" "$newname" ; done
new list “test-file1.txt test-file2.txt test-file3.txt test-file4.txt”
Remove the extension from file names
for i in $(ls); do mv $i ${i%.*}; done
Remove a prefix from file names
for i in $(ls *.txt); do mv $i ${i#*-};done
using a for loop and mv
for file in $(ls); do mv -i "${file}" "${file/Disc_1_-_/}"; done
this
Disc_1_-_01_-_Bright_Side_of_the_Road.m4a Disc_1_-_02_-_Gloria.m4a Disc_1_-_03_-_Moondance.m4a Disc_1_-_04_-_Baby_Please_Don_t_Go.m4a
becomes
01_-_Bright_Side_of_the_Road.m4a 02_-_Gloria.m4a 03_-_Moondance.m4a 04_-_Baby_Please_Don_t_Go.m4a