Back to articles
June 21, 2024
bash, file rename

2021-05-24-bash-rename-file-extension

# Rename all *.html to *.markdown
for f in *.html; do 
    mv -- "$f" "${f%.html}.markdown"
done

-- marks the end of the option list.
* This avoids issues with filenames starting with hyphens.
${f%.html} is a parameter expansion
* and is replaced by the value of f with .html removed from the end.
Loading comments...