Home > OS >  How To Add Line Break <br> In CMD Command In Batch File
How To Add Line Break <br> In CMD Command In Batch File

Time:08-27

I want to add a line break in a batch file here is the code

for %%I in (*.mp4) do (
    set "FullFileName=%%I"
    set "OnlyFileName=%%~nI"
    setlocal EnableDelayedExpansion
    set "FullFileNameTrim=!OnlyFileName:_=!"
    set "FullFileNameTrim=!OnlyFileName:~9!"
    
    set "OnlyFileName=!OnlyFileName:_= !"
    set "OnlyFileName=!OnlyFileName:-= !"
    set "n=!^&echo.!"
    set "OnlyFileName=!OnlyFileName:(=%n%!"
    set "OnlyFileName=!OnlyFileName:~9!"
    ffmpeg.exe -i "!FullFileName!" -vf "drawtext=text=!OnlyFileName!:fontfile='C\:\\Users\\harin\\Desktop\\test\\Fonts\\Glamy Sunrise.ttf':fontcolor=black:fontsize=54:x=20:y=50" -b:v 1M -r 60 -b:a 144k -crf 17 "C:\Users\harin\Desktop\test\in\Working\1\!FullFileNameTrim!.mp4"
    endlocal
)
endlocal

I am not able to put line break by using

set "n=!^&echo.!"
    set "OnlyFileName=!OnlyFileName:(=%n%!"

Is there a way I can add a line break

Thanks

CodePudding user response:

Example

@echo off
setlocal enabledelayedexpansion
set ^"LF=^


rem Do not delete the above two empty lines
echo this will have a !LF!new line here

where you will then use !LF!

as an example by using only parts of your code:

@echo off
setlocal enabledelayedexpansion
set LF=^


for %%I in (*.mp4) do (
    set "OnlyFileName=%%~I"
    for %%a in ("!LF!") do set "OnlyFileName=!OnlyFileName:(=%%~a!"
    echo !OnlyFileName!
    set "OnlyFileName=!OnlyFileName:~9!"
)
  • Related