I want to use batch implementation to import text to s.txt multiple times, for example: "AAAA", "bbbb", "CCCC", "dddd"
Achieve s.txt effect such as:
Aaaabbbbccccdddd
However, the echo command will force a newline each time it is imported, such as:
Aaaa
bbbb
Cccc
dddd
How do I achieve the one-line effect I want? Thank you!
Answer:
Echo cannot do this, but you can execute the following statement to achieve the goal
Copy Code code as follows:
>>s.txt set/p= "AAAA" <nul
>>s.txt set/p= "BBBB" <nul
>>s.txt set/p= "CCCC" <nul
>>s.txt set/p= "dddd" <nul
S.txt's content will be aaaabbbbccccdddd
Note 1: ">>s.txt" here is the meaning of output flow direction, the output stream to the S.txt file, "<nul" is the input stream designated as NUL, so set/p= "AAAA" does not have to wait for user input.
In fact, put the file operation to the back easier to understand some: set/p= "AAAA" <nul>>s.txt
Note 2: For more information about set/p= "AAAA" Please check the SET command
Example 1:
If exist%statfile2% (>>%statfile2% Set/p=,%%i<nul) Else (>>%statfile2% Set/p=%%i<nul)
Instance 2----(personal add)
Copy Code code as follows:
@echo off
Del B.txt
Del C.txt
Del D.txt
If exist "%cd%\zhi386" rd/s/q "%cd%\zhi386"
MD zhI386
:: for/r "%cd%\eni386\"%%i in (*) do (echo%%i>>b.txt)
for/f%%i in (' dir/b%cd%\eni386\ ') do (
Echo%%i>>c.txt
If exist "%cd%\zhall\i386\%%i" (copy "%cd%\zhall\i386\%%i" "%cd%\zhi386\"
Else (>>d.txt set/p= "zhall\i386\%%i" <nul&echo----not exist>>d.txt)
)
Windows Batch Six-echo output does not wrap
Complete case:
Code:
Copy Code code as follows:
@echo off
set/p= "Hello" <nul
Set/p= "World" <nul
Echo again
Echo New Line
Result:
Hello World again
New Line
Application:
Copy Code code as follows:
echo off
Set csvpath= test data
Set SQLULDR=D:\SQLULDR\SQLULDR2SDK\SQLULDR2
Set Sqlpath= export Template
REM Set Filename= product quotes
REM SQLULDR2 gtcustomer/passwd file=%csvpath%\%filename%.csv text=csv field=, Sql=exp%filename%.sql log=%csvpath%\% Filename%.log
Rem
REM Set Filename= product quotes update
REM SQLULDR2 gtcustomer/passwd file=%csvpath%\%filename%.csv text=csv field=, Sql=exp%filename%.sql log=%csvpath%\% Filename%.log
Set expfpath= millions
Echo Exports%expfpath% data:
For%%i in (%sqlpath%\%expfpath%\exp*.sql) do (
set/p= "Export data:%%~ni" <nul
%sqluldr% gtcustomer/passwd file=%csvpath%\%expfpath%\%%~ni.csv text=csv field=, sql=%%i log=%csvpath%\%expfpath%\%% ~ni.log
echo ..... ... ok.
)
Set Expfpath= Tens
Echo Exports%expfpath% data:
For%%i in (%sqlpath%\%expfpath%\exp*.sql) do (
set/p= "Export data:%%~ni" <nul
%sqluldr% gtcustomer/passwd file=%csvpath%\%expfpath%\%%~ni.csv text=csv field=, sql=%%i log=%csvpath%\%expfpath%\%% ~ni.log
echo ..... ... ok.
)
Pause