Run random script from a folder Topic is solved
Run random script from a folder
Currently i'm trying to do so that every time i run my script it opens a random one between 3 files (or even more).
Re: Run random script from a folder Topic is solved
Code: Select all
#Requires AutoHotkey v1.1.33
dir := A_ScriptDir "\t"
fn := ["1.txt", "2.txt", "3.txt"]
Random rnd, 1, fn.Length()
Run % dir "\" fn[rnd]
Re: Run random script from a folder
i don't quite understand the last part. what's supposed to be instead of "\"?mikeyww wrote: ↑28 May 2023, 06:00Code: Select all
#Requires AutoHotkey v1.1.33 dir := A_ScriptDir "\t" fn := ["1.txt", "2.txt", "3.txt"] Random rnd, 1, fn.Length() Run % dir "\" fn[rnd]
Re: Run random script from a folder
it doesn't seem to work, it says couldn't find the file
Re: Run random script from a folder
The fn array isn't meant to contain full paths. It's meant to be file names that are in a sub-directory of the script's directory named "t". So you would put your three test files in a folder named "t" in the folder that your script is in.
Re: Run random script from a folder
thank you very much, now it works like a charm :O
Re: Run random script from a folder
If your fn is meant to include the full path, then you will not need the dir at all. You would also need to specify the files themselves unless you want to use Loop Files to retrieve them. The bottom line is that you need to examine your script to understand what it is doing.