I'm creating a batch script, which will allow me to change any type of files to another. But i have problems with getting the file names from folder. %%~nxi contains file name, but i cant write it to a variable, so i cant use it. And also I have problems with how to add an extension to the file name:
magick convert "file1.jpg" "folder\file2.png"
How i can make "file2.png" using variable and .png extension? My ideas:
"folder\{file_name}.png"
"folder\!file_name!.png"
"folder\%file_name%.png"
Batch script:
set png_folder=PNG
set jpg_folder=JPG
for /f "delims=" %%i in ('dir /b "%jpg_folder%"') do (
set file_name="%%~nxi"
:: file_name is always empty
magick convert "%%f" "%png_folder%\{file_name}.png"
)
pause