RichardT Posted April 22, 2010 Share Posted April 22, 2010 Hello Again! I am trying to do something easy I bet, but am at a loss. I need to rename a file called AMT000.xml to the name of a variable ($sInput) with a .xml extention. The file AMT000.xml gets written with an output of a WLAN profile. I need the name to change so I can import it in to a system with the new name. I am trying to automate it, but I do not know how to use the variable? I get the $sInput from an InputBox. Thoughts? "so much work, so little brains..." Link to comment Share on other sites More sharing options...
jchd Posted April 22, 2010 Share Posted April 22, 2010 Code? No code? Helpfile lookup? FileMove() This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RichardT Posted April 22, 2010 Author Share Posted April 22, 2010 Sorry. This is the command I am using to create the file... RunWait(@ComSpec & " /c " & "WLAN.exe gp 70768bfc-d0e8-4630-a985-8843575194af AMT000.xml") The file will look like this: ********************************Beging output********************************* The return profile xml is: <?xml version="1.0"?> <WLANProfile xmlns="http://www.microsoft.com/networking/WLAN/profile/v1"> <name>AMT000</name> <SSIDConfig> <SSID> <hex>414D54303030</hex> <name>AMT000</name> </SSID> </SSIDConfig> <connectionType>ESS</connectionType> <MSM> <security> <authEncryption> <authentication>WPA2PSK</authentication> <encryption>AES</encryption> <useOneX>false</useOneX> </authEncryption> <sharedKey> <keyType>networkKey</keyType> <protected>false</protected> <keyMaterial>B961A4F20B0B81293EB70EF6B56AE2CB3316DD885B38D43B0CDB5868CE832FB1</keyMaterial> </sharedKey> </security> </MSM> </WLANProfile> Command "gp" completed successfully. ************************************End output******************************* I run another snippet that replaces text: $sFileName = "AMT000.xml" $sFindText = "<name>AMT000</name>" $sReplaceText = "<name>" & $sInput & "</name>" $sFileContents = FileRead($sFileName) $sFileContents = StringReplace($sFileContents, $sFindText, $sReplaceText) FileDelete($sFileName) FileWrite($sFileName,$sFileContents) Now I have to rename the file with the variable name $sInput with a .xml extention. "so much work, so little brains..." Link to comment Share on other sites More sharing options...
jchd Posted April 22, 2010 Share Posted April 22, 2010 Aren't you overcomplicating the baby? Couldn't you create the file with the right name in the first place? If really no, then: $sFileName = "AMT000.xml" $sFindText = "<name>AMT000</name>" $sReplaceText = "<name>" & $sInput & "</name>" $sFileContents = FileRead($sFileName) $sFileContents = StringReplace($sFileContents, $sFindText, $sReplaceText) FileDelete($sFileName) FileWrite($sInput & '.xml', $sFileContents) Else, as I said (albeit a bit dry) FileMove() This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
RichardT Posted April 22, 2010 Author Share Posted April 22, 2010 Thanks for the Help!! I wish I could, but I work for a train company, and a profile has to be uploaded to every P42 GE engines, which there are ove 325 of them. I don't want to touch all of these because the FRA inspectors need access via WIFI. (freakin government losers). Again, thanks for your help!! "so much work, so little brains..." Link to comment Share on other sites More sharing options...
jchd Posted April 22, 2010 Share Posted April 22, 2010 No problem, you're welcome. This one was easy, but the important point is that it works for you then you've learned to FileMove() in case you need it some day. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) 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