logo
down
shadow

Save text in UTF-8 via Batch


Save text in UTF-8 via Batch

By : Nhớ Tên Tui
Date : November 16 2020, 06:23 AM
this one helps. It took a bit of experimentation, but I successfully tweaked Simon Sheppard's UCS-2 encode method to encode a file as UTF-8 with batch.
code :
@echo off
setlocal

:: utf8.bat infile outfile
:: convert infile to utf8 and save as outfile

if not exist "%~1" goto usage
if "%~2"=="" goto usage

set "infile=%~f1"
set "outfile=%~f2"

:: store current console codepage to var
for /f "tokens=2 delims=:" %%I in ('chcp') do set "_codepage=%%I"

:: temporarily change console codepage to UTF-8
>NUL chcp 65001

:: set byte order mark for outfile
>"%outfile%" set /p "=" <NUL

:: dump infile to outfile encoded as UTF-8
>>"%outfile%" type "%infile%"

:: restore console to original codepage
>NUL chcp %_codepage%

goto :EOF

:usage
echo Usage: %~nx0 infile outfile


Share : facebook icon twitter icon
Batch File Issue - Save Input To Text With Spaces

Batch File Issue - Save Input To Text With Spaces


By : Alberto Maglia Drumm
Date : March 29 2020, 07:55 AM
will be helpful for those in need I think the problem is when you compare the user's input with CLS. Try to put quotes in %NotesEnter% when compare the value like this :
code :
@echo off

color 9F
title Notes
CLS

del %UserProfile%\Documents\Notes.txt
echo Issue/Request: >> %UserProfile%\Documents\Notes.txt

:StartCallNotes
CLS

echo ================== Notes =================
type %UserProfile%\Documents\Notes.txt
echo ==========================================

set /p NotesEnter=Enter Notes: 

set NewNote="%NotesEnter%"

REM if user doesn't input the value echo a new line
if "%NotesEnter%" == "" echo. >> "%UserProfile%\Documents\Notes.txt"

if "%NotesEnter%" == CLS goTo :CLS

if NOT "%NotesEnter%" == "" echo %NotesEnter% >> "%UserProfile%\Documents\Notes.txt"

REM reset the variable value
set NotesEnter=

goTo :StartCallNotes

:CLS
del %UserProfile%\Documents\Notes.txt
echo Issue/Request: >> "%UserProfile%\Documents\Notes.txt"
goTo :StartCallNotes

exit
Save specific line from text via batch

Save specific line from text via batch


By : user2192289
Date : March 29 2020, 07:55 AM
Does that help So I'm trying to save the contents from the second line of a text file as a variable using Batch. I know there are way better scripting languages to do this with, but batch has command line simplicity that I need. I found this webpage: http://www.netikka.net/tsneti/info/tscmd023.htm But it seems that this method requires an auxiliary program called SED be installed. Are there any methods that do not require SED? , A for loop could work ..
code :
     @echo off

     Setlocal enabledelayedexpansion

     For /f "skip=1 tokens=*" %%a in (myfile.txt) do (

     Set secondline=%%a 

     goto finish

     )

    : finish

    Echo this is my variable !secondline!

    Pause
How I can run commands using batch and save the output in text file?

How I can run commands using batch and save the output in text file?


By : Trịnh Hồng Điệp
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Two choices:
Redirect (">") your commands in the .bat file directly, as you invoke them
code :
echo %DATE% %TIME% > mylog.txt
cmd1 >> mylog.txt
cmd2 >> mylog.txt
...
call mybatfile.bat > mylog.txt
Batch : Echo can not save to text file

Batch : Echo can not save to text file


By : Satar Indhar
Date : March 29 2020, 07:55 AM
hop of those help? The easy way is to escape the ) characters that are erroneously being interpreted as end-of-statement with a caret ^
Hence (2 carets inserted)
code :
echo OPTIONS (SKIP=0, errors=1000^) LOAD DATA  APPEND INTO TABLE tb_data FIELDS TERMINATED BY X'09' TRAILING NULLCOLS (no "TRIM (:no)",date_pymn DATE "DD-MM-YYYY"^) > data.ctl
for /f "tokens=5" %%a in ('findstr /L "Total " max_page.csv') do set max_page%%a
Save response of web service to JSON text files in batch

Save response of web service to JSON text files in batch


By : user1256752
Date : March 29 2020, 07:55 AM
help you fix your problem You can use something like curl, wget or aria2 to download a list of files. see this command: aria2c -j5 -i list.txt
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org