A: |
To my knowledge there isn't a variable that will return you a random file name, however you could use one of the following techniques:
- Use the random function to derive a random number and then check to see if the file exists using the FileExists function, looping until you get a new file
OR
- Use a combination of date and time variables (obtained from GetDate and GetTime), manipulating them to remove illegal characters (/ and :) to derive a file name. (Again I'd check to ensure the file didn't exist before using the derived name, if it did I'd append a sequence number to ensure uniqueness).
OR
- If no other process writes to the directory where you will store these files AND you do not delete files from the directory, then you could use the DirList function to return you the number of files in the directory (even specifying a matching pattern if necessary), count the number of lines (using the LineCount) function and then derive a unique name. The following (untested) script commands should
accomplish this task:
{ Initialize the "$dir" variable to the drive and path to which the files are to be saved.
Set $dir "C:\my documents\"
{ Obtain a list of the ".txt" files currently in the directory.
DirList $list $dir "*.txt"
{ Count the number of ".txt" files currently in the directory.
LineCount #l $list
{ Increment the count by 1
Inc #l
{ Initialize the file name to the drive and path
Set $filename $dir
{ Generate the file name, all files will be sequentially numbered
AddStrings $filename #l ".txt"
|