AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

FileAppend automater

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Fri Jun 18, 2004 10:46 am    Post subject: FileAppend automater Reply with quote

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
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Jun 18, 2004 12:24 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message Send e-mail
Rajat



Joined: 28 Mar 2004
Posts: 1717

PostPosted: Fri Jun 18, 2004 6:47 pm    Post subject: Reply with quote

done!
_________________
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group