Rajat
Joined: 28 Mar 2004 Posts: 1717
|
Posted: Fri Jun 18, 2004 10:46 am Post subject: FileAppend automater |
|
|
This script will create an ahk script to generate the input file on target system using FileAppend.
In other words, give it an input file, and the name of the output file and it'll create Generated.ahk, that when run, will create the output file on the system whose contents will be identical to input file.
(i usually use FileAppend for small (text) files and prefer it over FileInstall)
| Code: |
input = %1%
ifnotexist, %input%, FileSelectFile, input, 1,, Select File to be scanned:
FileSelectFile, Output, ,, Select File to be Generated:
FileDelete, Generated.ahk
Loop, Read, %input%, %a_scriptdir%\Generated.ahk
{
StringReplace, ReadLine, A_LoopReadLine, ``, ````, A
StringReplace, ReadLine, ReadLine, `,, ```,, A
StringReplace, ReadLine, ReadLine, `;, ```;, A
StringReplace, ReadLine, ReadLine, `%, ```%, A
FileAppend, FileAppend`, %ReadLine%``n`, %output%`n
}
|
_________________

Last edited by Rajat on Fri Jun 18, 2004 6:46 pm; edited 1 time in total |
|
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jun 18, 2004 12:24 pm Post subject: |
|
|
| Nice. A small improvement: Any time you use a file-reading loop to create another file, use that file as the loop's last parameter. This improves performance because the file does not have to be reopened for each append. Then, when using FileAppend inside the loop, omit the filename parameter so that the loop's output file will be used. |
|