I have a script that reads the files in a directory to a list, opens those in a separate program, and then saves the resulting data with the same file name (in a different directory) as a text file using notepad. The script works fine but occasionally there are some issues with writing the file names that I don't understand.
All of the file names are in the format '####Mmm#(#(#(#))).txt' (number padded to 4 digits with zeros, month as three letters with the first one capitalized, number not padded with zeros. The problems that come up are:
in the results text file the first letter of the month is not capitalized
the first number is written as its corresponding symbol (# for 3, $ for 4, % for 5, etc). This is especially an issue, because when the number includes an 8 (*), the file cannot save.
Any ideas where I've gone wrong? Thanks!
$filelist = _FileListToArray( @WorkingDir )
For $iter = 1 To $filelist[0] Step 1
$curfile = $filelist[$iter]
...
;do some stuff that ends with data being copied to clipboard
...
Run('notepad.exe')
WinWaitActive('Untitled - Notepad')
Send('^v') ;paste clipboard
WinClose('Untitled - Notepad')
WinWaitActive('Notepad', 'Save')
Send('!S') ;press save
WinWaitActive('Save As')
ControlSend('Save As','','[CLASS:Edit; INSTANCE:1]','^a'&'{BACKSPACE}') ;clears text in field
ControlSend('Save As','','[CLASS:Edit; INSTANCE:1]',$curfile&'{ENTER}') ;pastes file name and hits enter