Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

FileAppend automater


  • Please log in to reply
2 replies to this topic
Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
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)

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
}

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
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.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
done!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat