Ini File Creator

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Marcus Tettmar
Site Admin
Posts: 7380
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Ini File Creator

Post by Marcus Tettmar » Thu Mar 12, 1998 12:00 am

Contributed By: Richard Heaton [email protected]
Submitted On: 12/03/98

;Script to create an ini file containing all of a specified type of file
;in a specified folder which could be used in a script to change
;wallpaper (search for bmp) or screensavers (this example)

;Path=Folder to create the ini file in (must exist & recommend empty)
Let>Path=c:\windows\screensaver

;File=name of ini file and ini section to be created
Let>File=savers

;Search=Folder to search for matching files
Let>Search=c:\windows

;Type=Extension of file type to list
Let>Type=scr

;Subs=Yes to include subfolders or No if not
Let>Subs=Yes

;Deletes previous ini file
DeleteFile>%Path%\\%File%.ini

;Include subdirectories check ?
If>%Subs%=Yes,Yes
Goto>No
Label>Yes

;dir of folder and sub-folders piped into text file
Run Program>command.com /c dir %Search%\*.%Type% /s/b >%Path%\\%File%.txt
Goto>Run
Label>No

;dir of folder piped into text file
Run Program>command.com /c dir %Search%\*.%Type% /b >%Path%\\%File%.txt
Label>Run
WaitWindowOpen>MS-DOS*
WaitWindowClosed>MS-DOS*

;Opens created text file in notepad
Execute File>%Path%\\%File%.txt
WaitWindowOpen>%File%.txt*
SetFocus>%File%.txt*

;Marks end of file
Press CTRL
Press End
Release CTRL
Send Character/Text>z
Press CTRL
Press Home
Release CTRL

;Inserts ini section name
Send Character/Text>[%File%]
Press Enter
Let>Count=0

;Starts loop to add numbers
Label>Start
Add>Count,1

;Checks first letter of line to ensure not z (ie end of file)
Press Shift
Press Right
Release Shift
Press ALT
Release ALT
Send Character/Text>EC
Wait>0.1
GetClipBoard>Clip
If>%Clip%=z,End

;Inserts number and =
Press Left
Send Character/Text>%Count%=
Press CTRL
Press Left
Release CTRL
Press Down

;Next loop
Goto>Start

;inserts max=one above last number
Label>End
Press Del
Send Character/Text>max=%Count%

;saves ini file, closes notepad and deletes text file
Press ALT
Release ALT
Send Character/Text>FA
Send Character/Text>%File%.ini
Press Enter
Press ALT
Release ALT
Send Character/Text>FX
DeleteFile>%Path%\\%File%.txt

;Then End

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts