Hi All,
Happy New Year to you all!!!
It is a great forum here in which I can have your help....
I have a txt file showing like this:
500006011000.S3S
500007011000.S3S
500008011000.S3S
500009011000.S3S
500010011000.S3S
500012011000.S3S
500014011000.S3S
500016011000.S3S
500134010100.S3S
500028011201.S3S
500129010200.S3S
500015011000.S3S
500142010100.S3S
500144010100.S3S
Now I would like to chop off some substrings and become sth. like this in another txt file: Basically keep first 6 digits then using * for the rest and keep .S3S at the end.
500006*.S3S
500007*.S3S
500008*.S3S
500009*.S3S
500010*.S3S
500012*.S3S
500014*.S3S
500015*.S3S
500016*.S3S
500028*.S3S
500129*.S3S
500134*.S3S
500142*.S3S
500144*.S3S
Thanks
How to chop off substrings in the txt file
Moderator: DosItHelp
Re: How to chop off substrings in the txt file
This is basic string manipulation as described here. Lots of examples for you to look at.
Re: How to chop off substrings in the txt file
Let take a trip back on memory lane.
Re: How to chop off substrings in the txt file
Untested:
Steffen
Code: Select all
setlocal EnableDelayedExpansion
>"another.txt" (
for /f "usebackq delims=" %%i ("original.txt") do (
set "n=%%~ni"
echo !n:~,6!*%%~xi
)
)
endlocal
Re: How to chop off substrings in the txt file
Thanks Steffen!aGerman wrote: ↑09 Jan 2018 14:55Untested:SteffenCode: Select all
setlocal EnableDelayedExpansion >"another.txt" ( for /f "usebackq delims=" %%i ("original.txt") do ( set "n=%%~ni" echo !n:~,6!*%%~xi ) ) endlocal
I use this code:
Code: Select all
@echo off
call C:\auto_pkg_build\Scripts\scheme_replace\varconfig.cmd
set VAR14=%VAR14:~8%
cd "C:\auto_pkg_build\Tools\PACKAGER\S3S\TELIUM3\%VAR14%"
setlocal EnableDelayedExpansion
>"trim_generic.txt" (
for /f "usebackq delims=" %%i ( "generic.txt" ) do (
set "n=%%~ni"
echo !n:~,6!*%%~xi
)
)
endlocal
("generic.txt" was unexpected at this time.
Re: How to chop off substrings in the txt file
Missing the IN.
Re: How to chop off substrings in the txt file
Thanks for your reminding and works....
BTW, I used the memory line you mentioned and modified code to be like this
Code: Select all
@echo off
call C:\auto_pkg_build\Scripts\scheme_replace\varconfig.cmd
set VAR14=%VAR14:~8%
cd "C:\auto_pkg_build\Tools\PACKAGER\S3S\TELIUM3\%VAR14%"
if exist trim_generic.txt (del trim_generic.txt)
setlocal enabledelayedexpansion
for /f "delims=" %%i in (generic.txt) do (
set line=%%i
echo !line:~,6!*.S3S>>trim_generic.txt
)