Simple script to compile all files in a given directory

Post your working scripts, libraries and tools for AHK v1.1 and older
needle
Posts: 5
Joined: 18 Apr 2018, 07:20

Simple script to compile all files in a given directory

26 Nov 2018, 13:54

Hello guys,
I wrote a software made by a bunch of scripts and it was a pain in the arse to compile them individually, so I wrote a very simple script that takes all files in a source dir and compile them to a target dir.
I kept all parameters in variables, so it will be extremely easy for you to customize the script.
I also added a cool progress bar.
Enjoy!

Code: Select all

#SingleInstance Force

compiler := "Ahk2Exe.exe"
bin := "Unicode 64-bit.bin"
mpress := "1"
directory_compiler := "Z:\AutoHotkey_1.1.30.01\Compiler\"
directory_in := "Z:\Source\"
directory_out := "Z:\Target\"

count := 1
FileList = ; Initialize to be blank.
Loop, Files, %directory_in%*.ahk
    {
    if A_LoopFileName = compile.ahk ; Ignore this script in the compiling process. 
        {
        count := count - 1
        Continue
        }
    FileList = %FileList%%A_LoopFileName%`n
    inverse_count := count := count + 1
    }
If FileList =
    {
    MsgBox, 262192, Error, No Files Found!
    Exit
    }
Sort, FileList

Progress, R1-%count%,, %inverse_count% files to be compiled..., Compiling %count% files
Loop, parse, FileList, `n
    {    
    if A_LoopField != ; Ignore the blank item at the end of the list.
        {
        SplitPath, A_LoopField , , , , cleaname
        RunWait %directory_compiler%%compiler% /in "%directory_in%%cleaname%.ahk" /out "%directory_out%%cleaname%.exe" /bin "%directory_compiler%%bin%" /mpress "%mpress%"
        Progress, %A_Index%,, %inverse_count% files to be compiled..., Compiling %count% files
        inverse_count := inverse_count - 1
        }
    Else
        {
        Progress, OFF
        MsgBox, 262208, Success, %count% Files Compiled!
        Break
        }
    }

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 123 guests