chris.ujs Posted February 7, 2006 Share Posted February 7, 2006 Good morning Ladies and Gentlemen,I'm appealing to the scripting gurus out there for, (hopefully) a simple fix for my current issue.I have a script that removes quotation marks from a text file, simple enough.Currently, the script opens each txt file by name in order to do this, which wasn't a huge problem when I had 11 txt files, but now I'm adding ~70 more and adding a section for each by name would be quite cumbersome.Rather, it would be more elegant to be able to pass a variable into the script so it knows the txt file to open.What I'm hoping for:A batch file that I can run my script from with something similar to the following linequotes.exe pr.txt -- where quotes.exe is a compiled script that grabs pr.txt as the variable of what to open. My current attempt(which, obviously doesn't work) is below. Also, if anyone can come up with a better way to accomplish this, I'd be most grateful. A flexible script that could replace any txt with any txt would be wonderful(IE being able to pass multiple variables, txt file, txt to be replaced, replacement string) Thank you all in advance for any advice or direction Example of my batch fileFOR /F %%I in (cities.txt) DO CALL :_quotes %%IGOTO :EOF:_quotesEcho %time% - Calling quotes.exestart /w quotes.exe %1GOTO :EOFscript code; Script Function:; Opens Notepad, removes quotes and then quits.;dim $txt = $CmdLine[1]; Run NotepadRun("notepad.exe $txt"); Wait for the Notepad become active - it is titled "$txt.txt - Notepad" on English systemsWinWaitActive("$txt - Notepad"); Now that the Notepad window is active replace " with (space)Send("!e")Sleep(50)Send("r")Sleep(50)Send("+'")Sleep(50)Send("{TAB}{TAB}{TAB}{TAB}{TAB}")Sleep(50)Send("{ENTER}")Send("{TAB}")Sleep(50)Send("{ENTER}")Sleep(50)Send("!f")Send("x")WinWaitActive("Notepad", "No")Send("y")WinWaitClose("$txt - Notepad") Link to comment Share on other sites More sharing options...
herewasplato Posted February 7, 2006 Share Posted February 7, 2006 Change:WinWaitActive("$txt - Notepad")To:WinWaitActive($txt & " - Notepad")Do the same with:WinWaitClose("$txt - Notepad")(There are more reliable ways to use AutoIt to change a text file... but we will save that for another post.) [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
JSThePatriot Posted February 7, 2006 Share Posted February 7, 2006 Might want to look into FileReadLine(), FileWriteLine(), StringInStr(), and StringReplace(). Those will always help you greatly. JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now