Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
Batch File-change space with tab
Name: Spiderman Date: July 30, 2008 at 01:01:17 Pacific OS: XP CPU/Ram: 1 GB Product: Dell
Comment:
Hi, I have a text file with 4 words, space delimited.I need a batch file which replaces the 2 spaces between the first 3 words with a tab, and the last space remains unchanged. Input: Mary(space)John(space)Elly(space)Linda Output: Mary(tab)John(tab)Elly(space)Linda
I found this code, but it replaces all spaces with tab: @echo off & setlocal EnableDelayedExpansion (set TAB= ) for /f "delims=" %%i in (myfile.txt) do ( set row= for %%j in (%%i) do (set row=!row!%%j!TAB!) set row=!row:~0,-1! echo.!row!> myfile.txt )
Does anybody know how can I do that? Thank you!
"He who asks is a fool for five minutes, but he who does not ask remains a fool forever" Chinese Proverb
Name: Elinor Date: July 30, 2008 at 01:27:08 Pacific
Reply:
How about:
@echo off & setlocal EnableDelayedExpansion set TAB= set SPACE= for /f "delims=" %%i in (myfile.txt) do ( set row= set count=0 for %%j in (%%i) do ( set /A count=!count!+1 set char=%TAB% if !count!==3 set char=%SPACE% set row=!row!%%j!char! ) set row=!row:~0,-1! echo.!row! > myfile2.txt )
Summary: I need a batch file script to replace the spaces with tab in a text file. (text file has few hundred lines) however i use the below script @echo off & setlocal EnableDelayedExpansion (set TAB= ) for /...
Summary: Hi Klint, Didn't work for me rundll32 shell32.dll,ShellExec_RunDLL "C:\prog.lnk" (I copied pasted it in the batch file) Tried it with both batch file and a link called prog.lnk in in root C:\ and got ...
Summary: Hi 25zerotwo, Long back, I had written a batch file called duplicate.bat to find duplicate files. I think what you are asking is same as what this batch file does. It expects the filenames in filelist...