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 to insert string
Name: kens321 Date: June 12, 2009 at 04:38:43 Pacific OS: Windows XP Subcategory: Batch
Comment:
Hi
I need some help i have a file called myfile.txt and I want to create a batch file to insert a character in the beginning of every line in my file.
:: INCHR.BAT Usage: inchr Your_Character
@echo off > MyFile.new
for /F "delims=" %%j in (MyFile.txt) do echo.%1%%j>> MyFile.new
:: End_Of_Batch
I'm sure ghostdog will offer a better solution in Python.
0
Response Number 2
Name: Mechanix2Go Date: June 12, 2009 at 06:05:25 Pacific
Reply:
Hi IVO,
"I'm sure ghostdog will offer a better solution in Python."
Sure, but how many have python installed? One in 30,000?
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 3
Name: ghostdog Date: June 12, 2009 at 08:38:57 Pacific
Reply:
>>Sure, but how many have python installed? One in 30,000?
that's the reason why there are converters to convert Python ( or Perl) code into exe for distribution. Python (or other prog lang) can be downloaded and installed to 1 machine for development purposes. after testing and acceptance, convert to exe and distribute. This way, there is not much difference doing it in batch and distribute to every PC.
0
Response Number 4
Name: ghostdog Date: June 12, 2009 at 09:06:52 Pacific
Reply:
@OP, here's an alternative solution in Python
import sys,fileinput
position = int(sys.argv[1]) - 1
toinsert = sys.argv[2]
filename = sys.argv[3]
for line in fileinput.FileInput(filename,inplace=1):
line=list(line.strip())
line.insert(position,toinsert)
print ''.join(line)
usage: c:\test> python <position:integer> <word to insert> <filename>
Summary: Hej! i am new at dos batch files, so i need your help to notice what i am doing wrong. I have built a .NET program called JLMail which can send mail from command line, so i can execute from cmd promp...
Summary: I am using this batch file to delete profiles @echo off delprof /d:15 /q /i /c:\\COM0006 delprof /d:15 /q /i /c:\\COM0009 delprof /d:15 /q /i /c:\\COM0010 I want to get the name of the computers from ...
Summary: Hi I am currently trying to create a batch file to read text from a file, display it on the screen updating it every 2 seconds and beep if it finds something new, I have been able to get it to do ever...