Solved Create .bat file to add text line to .ini file?

April 12, 2016 at 13:20:05
Specs: Windows 7
I have the need to create a .bat file that will add a specific text line to a .ini file.

The text line should go specifically in one point of the .ini, otherwise it won't show a Toolbar that's needed.

It should go right after the [Environment] bracket and all of its content finishes.

The text line is:

[Toolbar]
OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files (x86)\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}

The .ini file location is C:\Windows\Dolphin.ini

Thanks for any help provided!


See More: Create .bat file to add text line to .ini file?

Report •

✔ Best Answer
April 20, 2016 at 21:59:12
::======  script starts here  ===============
:: insert [Toolbar] block
:: julio.bat  2016-04-21 11:16:14.73
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=1* delims=]" %%a in ('find /v /n "" ^< myfile') do (
  if %%b equ [Layouts] (
    echo.
    echo.[Toolbar]
    echo.OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files ^(x86^)\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}
    echo.
  )
echo.%%b
) >> newfile
::======  script ends here  =================

=====================

M2 Get custom script or take private lessons



#1
April 12, 2016 at 20:20:43
Is this A line or two lines?

[Toolbar]
OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files (x86)\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}

=====================

M2 Get custom script or take private lessons


Report •

#2
April 13, 2016 at 06:07:43
Yes, they are two lines, one for the Toolbar bracket and another one for the actual Toolbar

Report •

#3
April 13, 2016 at 06:55:19
Post your file.

20:55 2016-04-13

=====================

M2 Get custom script or take private lessons


Report •

Related Solutions

#4
April 20, 2016 at 10:08:34
Sorry for the delay. Below is the .ini file. As noted the Environment bracket is the first bracket on the file.

[Environment]
working=\\na-eortho-srv01\Dolphin\Working
archive=\\na-eortho-srv01\Dolphin\Archive
Imagelib=C:\Dolphin\Working
LandmarkPath=C:\Dolphin\Landmark
SoundPath=C:\Dolphin\Sounds\Margaret
Implants=\\na-eortho-srv01\Dolphin\Working\Implants
DIGI=C:\Dolphin\
SYS=C:\Dolphin\
UseDB=1
DolDBServer=192.168.1.50
;doldbserver=na-eortho-srv01
DolManagementExecutable=DMSMain.exe
SecurityKeyContactServer=
LastUpdateDate=04/20/09 16:20:00

[Layouts]
- Everything -=- Everything -,64,(1,5,0,0,95,95),(1,0,98,0,95,95),(3,7,198,0,95,95),(1,2,298,0,95,95),(1,3,398,0,95,95),(1,7,498,0,95,95),(1,6,598,0,95,95),(7,7,698,0,95,95),(2,0,0,98,95,95),(2,2,98,98,95,95),(2,1,198,98,95,95),(2,3,298,98,95,95),(2,4,398,98,95,95),(0,2,698,98,95,95),(5,0,0,198,95,95),(5,1,98,198,95,95),(5,2,198,198,95,95),(5,3,298,198,95,95),(5,4,398,198,95,95),(5,5,498,198,95,95),(5,6,598,198,95,95),(5,7,698,198,95,95),(3,6,0,298,95,95),(0,5,98,298,95,95),(0,6,198,298,95,95),(0,7,298,298,95,95),(2,6,398,298,95,95),(2,7,498,298,95,95),(1,4,598,298,95,95),(3,5,698,298,95,95),(0,1,0,398,95,95),(0,3,98,398,95,95),(0,4,198,398,95,95),(3,0,298,398,95,95),(3,2,398,398,95,95),(3,1,498,398,95,95),(3,3,598,398,95,95),(3,4,698,398,95,95),(6,0,0,498,95,95),(6,1,98,498,95,95),(6,2,198,498,95,95),(6,3,298,498,95,95),(6,4,398,498,95,95),(6,5,498,498,95,95),(6,6,598,498,95,95),(6,7,698,498,95,95),(7,0,0,598,95,95),(7,1,98,598,95,95),(7,2,198,598,95,95),(7,3,298,598,95,95),(7,4,398,598,95,95),(7,5,498,598,95,95),(7,6,598,598,95,95),(1,1,698,598,95,95),(4,0,0,698,95,95),(4,1,98,698,95,95),(4,2,198,698,95,95),(4,3,298,698,95,95),(4,6,598,698,95,95),(4,7,698,698,95,95),(2,5,498,98,95,95),(0,0,598,98,95,95),(4,4,398,698,95,95),(4,5,498,698,95,95)
Composite (6)=composite (6),6,(1,0,0,0,86,99),(1,2,91,0,86,99),(1,3,183,0,86,99),(2,0,0,105,86,47),(2,2,91,105,86,47),(2,1,183,105,86,47)
Composite (10)=Composite (10),10,(1,0,0,0,144,167),(2,3,0,170,144,101),(2,0,0,275,144,79),(2,2,147,275,144,79),(2,4,295,171,144,101),(1,2,147,0,144,167),(1,3,295,0,144,167),(5,1,445,249,188,93),(2,1,295,275,144,79),(5,0,445,16,188,228)
Study Models (16)=Study Models,5,(3,0,0,0,150,100),(3,3,0,105,150,100),(3,4,310,105,150,100),(3,2,155,0,150,100),(3,1,310,0,150,100)
Radiographs (16)=Radiographs (16),16,(5,0,0,0,95,95),(5,1,98,0,95,95),(5,2,198,0,95,95),(5,3,298,0,95,95),(5,4,398,0,95,95),(5,5,498,0,95,95),(5,6,598,0,95,95),(5,7,698,0,95,95),(3,6,0,100,95,95),(0,5,98,100,95,95),(0,6,198,100,95,95),(0,7,298,100,95,95),(2,6,398,100,95,95),(2,7,498,100,95,95),(1,4,598,100,95,95),(3,5,698,100,95,95)
* Compare/Progress *=* Compare/Progress *,4,(1,3,0,0,144,167,"Initial"),(1,3,158,0,144,167,"progress"),(2,2,0,181,144,101,"initial"),(2,2,158,181,144,101,"progress")
* Compare/Final *=* Compare/Final *,4,(1,3,0,0,93,108,"initial"),(1,3,102,0,93,108,"final"),(2,2,0,117,93,65,"initial"),(2,2,102,117,93,65,"final")
* Compare/3 *=* Compare/3 *,6,(1,3,0,0,84,97,"initial"),(1,3,92,0,84,97,"progress"),(1,3,184,0,84,97,"final"),(2,2,0,105,84,59,"initial"),(2,2,92,105,84,59,"progress"),(2,2,184,105,84,59,"final")
* Surg Comp/Final *=* Surg Comp/Final *,6,(1,0,0,0,144,167,"Pre-Op"),(1,2,158,0,144,167,"Pre-Op"),(1,3,318,0,144,167,"Pre-Op"),(1,0,0,181,144,167,"Post-Op"),(1,2,158,181,144,167,"Post-Op"),(1,3,318,181,144,167,"Post-Op")
>Std 6=>Std 6,6,(1,0,15,0,90,112),(1,2,128,0,90,112),(1,3,243,0,90,112),(2,0,0,190,110,69),(2,2,118,190,110,69),(2,1,236,190,110,69)
>Std 8=>Std 8,8,(1,0,15,0,90,112),(1,2,128,0,90,112),(1,3,243,0,90,112),(2,3,0,130,110,69),(2,4,236,130,110,69),(2,0,0,210,110,49),(2,2,118,210,110,49),(2,1,236,210,110,49)
>Facials (3)=>Facials (3),3,(1,0,0,0,144,167),(1,2,158,0,144,167),(1,3,316,0,144,167)
>Std 9=>Std 9,9,(1,2,0,0,115,134),(1,3,135,0,115,134),(1,0,270,0,115,134),(5,3,405,0,115,134),(2,3,0,151,134,101),(2,4,386,151,134,101),(2,0,0,271,144,79),(2,2,188,271,144,79),(2,1,377,271,144,79)
>Std8+OpenBite=>Std8+OpenBite,9,(1,0,0,0,144,167),(1,2,158,0,144,167),(1,3,316,0,144,167),(2,3,0,181,144,101),(2,4,316,181,144,101),(2,0,0,296,144,79),(2,2,158,296,144,79),(2,1,316,296,144,79),(0,2,158,181,144,101)
Misc Photos (16)=Misc Photos (16),16,(6,0,0,0,95,95),(6,1,98,0,95,95),(6,2,198,0,95,95),(6,3,298,0,95,95),(6,4,398,0,95,95),(6,5,498,0,95,95),(6,6,598,0,95,95),(6,7,698,0,95,95),(7,0,0,100,95,95),(7,1,98,100,95,95),(7,2,198,100,95,95),(7,3,298,100,95,95),(7,4,398,100,95,95),(7,5,498,100,95,95),(7,6,598,100,95,95),(1,1,698,100,95,95)
Treatment forecast=Treatment forecasts,10,(1,0,0,0,95,95),(0,1,100,0,95,95),(4,0,0,102,95,95),(4,4,0,199,95,95),(4,1,100,100,95,95),(4,2,200,100,95,95),(4,3,300,100,95,95),(4,7,300,200,95,95),(4,6,200,200,95,95),(4,5,100,200,95,95)
>X-ray: Lateral=>X-ray: Lateral,1,(5,0,0,0,800,600)
>X-ray: Panoramic=>X-ray: Panoramic,1,(5,1,0,0,800,400)
>X-ray: Frontal=X-ray: Frontal,1,(5,2,0,0,600,800)
Digitized - Ceph Lateral=Digitized - Ceph Lateral,1,(0,1,0,0,205,215)
Digitized - Ceph Frontal=Digitized - Ceph Frontal,1,(0,3,0,0,764,800)
Digitized - Study Models=Digitized - Study Models,1,(0,4,0,0,764,800)
Composite (8)=Composite (8),8,(1,0,0,0,78,90),(1,2,85,0,78,90),(1,3,171,0,78,90),(2,3,0,96,78,54),(2,4,171,96,78,54),(2,0,0,157,78,42),(2,2,85,157,78,42),(2,1,171,157,78,42)
[Sequences]
- Facial-Intraoral-Occlusal -=  
- Lateral Ceph (Scan) -=  
- Pano (Scan) -=  
- Frontal/PA Ceph (Scan) -=  
- Lateral Ceph (Digital X-ray) -=  
- Pano (Digital X-ray) -=  
- Frontal/PA Ceph (Digital X-ray) -=  
- Models -=  
- Radiographs -=  
- Misc photos (16) -=  
- Everything -=  
- Facial-Intraoral -=  
- Facials ONLY-=  
- Intraoral-Occlusal -=  
- Quick -=  
- Std with Buccal Mirror -=  
[defaults]
CephPrefEnableTestMode=0
VTOInvertVertical=1
AMDeviationColor=1
UploadPort=10060
UploadIP=64.80.153.73
UploadURL1=https://www.anywheredolphin.com
UploadURL2=beta/upload/InternetServer.asp
UploadParam1=www.anywheredolphin.com
UploadParam2=/beta/upload/PatientUpload.asp?UID=
UploadImageLocation1=https://www.anywheredolphin.com
UploadImageLocation2=beta/imagesjpg
UploadToBeta=1
ArchiveFilePath=F:\\
AutoStartCharts=1
GoToCaptureAfterNewPatient=1
AutoCrop=1
TracingLineThicknessMMForPrinting=0.25
CaptureFromFilePath=e:\DCIM\100OLYMP;f:\DCIM\100OLYMP;e:\DCIM\100_FUJI;f:\DCIM\100_FUJI;e:\DCIM\100OLYMP;f:\DCIM\100OLYMP;e:\CAMERAO1\;f:\CAMERAO1\;e:\imfidx10;f:\imfidx10;e:\imjp0001;f:\imjp0001;P:\Patients
UseStamps=1
ImageToStampRatio=5
MinimumStampSize=300
ExposeVideoBatchPrintWindow=0
PrintButton=Print
MeasurementsMode=1
TracingOverlaysMode=0
AllowPatientChanges=1
MeasurementTableFontPointSize=12
TracingPrintTextScale=0.9
SelectPatientShowImages=1
SelectPatientSortedBy=0
Acquisition Image=X-ray Lateral
WindowPos=0,3,-1,-1,-4,-4,368,190,1163,770
Toolbar=1
Statusbar=0
Title=1
FitImages=1
BackgroundColor=192,192,192
Maximize Window when double-clicked=0
Side-By-Side when double-clicked=0
BackgroundBitmap=(None)
BitmapStyle=1
Layout=Composite (10)
ImageLoadStyle=1
Acquisition Sequence=- Facial-Intraoral-Occlusal -
SplashTime=2000
Acquisition Input=3
MorphBound=1
ImageFileType=LEAD
CompressionQFactor=5
ImageFileBitsPerPixel=24
SelectPatientImagePreviewDefaults=(FACIAL,FRONTSMILE),(FACIAL,FRONT),(DIGI,RIGHT),(DIGI,RIGHTXRAY)
WindowMaximized=1
OneClickMaximized=1
TruncMeasTracing=0
OneClickPreload=1
OneClickPreview=1
Country=USA
SilentDBMessage=0
OneClickLayoutInfo=0
OneClickTooltipInfo=0
OneClickUseBGColor=0
OneClickLockGuidelines=1
SlideShowMaximized=0
PatListColumnInfo=0 93 1 81
SingleInstanceUI=1
SaveOriginals=1
PromptOnExit=1
UploadSkipUncropped=0
IMAGE_ROTATION_FILL_ATTRIB=3 1 3
SelPatWindow=17,63,765,399
TurnOnIdNumberInToolTip=0
MeasWndNumDisplayPrec=1
MeasInTracingNumDisplayPrec=0
MeasurementsInColor=1
Questionnaire=New patient exam
VtoMoreIsOpened=0
DrawBrushSize=102
DrawBrushTransparency=100
DrawBrushFromMaxRatio=1.00
UploadUncropped=0
UploadRecipients=1
TurnOnTextGuides=0
DisplayPhotoCornerRoundedness=20
DisplayQuality=3
GrayCompressionQFactor=2
GrayImageFileType=JFIF
ImageFileOpenUseWin16=0
UseOldPatientList=0
EventsLog=1
CloakPatientNames=0
SaveIndividually=0
ImageEnhanceUsePreview=1
VtoShowImageMode=off
EditSubDialogPos=11 14
UseNewLayoutEditor=1
VerifyImageSave=1
PrintTracings=1


Report •

#5
April 20, 2016 at 21:59:12
✔ Best Answer
::======  script starts here  ===============
:: insert [Toolbar] block
:: julio.bat  2016-04-21 11:16:14.73
@echo off > NEWFILE & setLocal enableDELAYedeXpansioN

:main
for /f "tokens=1* delims=]" %%a in ('find /v /n "" ^< myfile') do (
  if %%b equ [Layouts] (
    echo.
    echo.[Toolbar]
    echo.OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files ^(x86^)\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}
    echo.
  )
echo.%%b
) >> newfile
::======  script ends here  =================

=====================

M2 Get custom script or take private lessons


Report •

#6
May 3, 2016 at 10:11:20
Thank you for the follow up! Sorry for my delay on the response. I tried yours and it didn't take any effect seemingly. I have been working on one of my own but mine creates two lines instead of one, and I cannot seem to understand why. Let me post my .bat file:

@echo off
Set file=Dolphin.ini
Ser section=[Toolbar]
Set newline=[Toolbar]OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}

find "%section%" < "%file%" > NUL || (
echo There is no %section% section already in file. Write new one.
(echo [Toolbar]OrthoCad=Models,Start OrthoCAD with this patient's info,c:\dolphin\buttons\orthocad.bmp,C:\Program Files\Cadent\OrthoCad\OrthoCad.exe -patient_id={PatientID}) >> "%file%"
(echo %newline%) >> "%file%"
goto finished
)


find "%newline%" < "%file%" > NUL && (
echo The new line already exists in the file. Do nothing:
goto finished
)

echo The %section% section was found so looking for the line to add after

copy /y "%file%" "%file%.old" >NUL
del "%file%"

for /f "tokens=*" %%l in (%file%.old) do (
(echo %%l)>> "%file%"
if /i "%%l"=="" (
echo Found %section% section, adding line
(echo %newline%)>> "%file%"
) 
)

:finished

echo.
echo Done.



Report •

#7
May 3, 2016 at 21:31:33
What's wrong with this line:

Ser section=[Toolbar]

=====================

M2 Get custom script or take private lessons


Report •

Ask Question