I think I would do something like this: for file in *.mdbuild; do newname=$(echo "$file" | sed 's/\.mdbuild$/.html/') mv "$file" "$newname" done Edit as needed for dir paths, etc.