Created
April 9, 2024 17:35
-
-
Save Infinitusvoid/f2ed3da8c7d664a5f6eed30bb46564df to your computer and use it in GitHub Desktop.
Bat : bash script that changes the files extension for all files in a folder to specefied one
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| setlocal enabledelayedexpansion | |
| rem Check if user provided the old extension and new extension | |
| if "%~2"=="" ( | |
| echo Usage: %~nx0 old_extension new_extension | |
| exit /b 1 | |
| ) | |
| set "old_extension=%~1" | |
| set "new_extension=%~2" | |
| rem Change extension for each file in the directory | |
| for %%F in (*.%old_extension%) do ( | |
| rem Get the filename without extension | |
| set "filename=%%~nF" | |
| rem Rename the file with the new extension | |
| ren "%%F" "!filename!.%new_extension%" | |
| echo Changed %%F to !filename!.%new_extension% | |
| ) | |
| echo All files with extension .%old_extension% are changed to .%new_extension% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| change_extension.bat txt csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment