Change extensions of all files in a folder

Aug 5, 2024·
Gert de Pagter
Gert de Pagter
· 1 min read

This week I wanted to change all the .js files to .ts recursively in a folder.

To change all .js files in the assets folder. With a bit of bash, using a for loop and mv I got the following command to rename all my .js to .ts files.

for f in assets/*.js; do mv -- "$f" "${f%.js}.ts"; done

If you want to get notified of the next blog post, join the newsletter.