shiv Posted September 23, 2013 Share Posted September 23, 2013 Hi AutoIT Help & Support I need your help to make my code generic here is the code Local $sFileList = _FileListToArray($sPath) ; at $sPath i have two files which have the extension .msi and .64msi $sFileList[1] = "File name1_.msi" $sFileList[2] = "File name2_x64.msi" In the above two lines of code i do not want to use file names. i want to use something like $sFileList[1] = "_.msi" $sFileList[2] = "_x64.msi" But when i use this files name are not recognized at the location of files is there some way that i can use the extensions to recognize the file Please Help Link to comment Share on other sites More sharing options...
shiv Posted September 23, 2013 Author Share Posted September 23, 2013 Please reply Link to comment Share on other sites More sharing options...
JohnOne Posted September 23, 2013 Share Posted September 23, 2013 Please reply Hi. Shrapnel 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
michaelslamet Posted September 23, 2013 Share Posted September 23, 2013 John, you're such a funny guy Link to comment Share on other sites More sharing options...
shiv Posted September 23, 2013 Author Share Posted September 23, 2013 thanks Link to comment Share on other sites More sharing options...
michaelslamet Posted September 23, 2013 Share Posted September 23, 2013 Vis, I think your request is not clear (at least for me). Could you please tell us again what exactly you're trying to accomplish? Link to comment Share on other sites More sharing options...
JohnOne Posted September 23, 2013 Share Posted September 23, 2013 thanks You're welcome. You need to just wait though, until someone knows an answers. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
shiv Posted September 23, 2013 Author Share Posted September 23, 2013 Hi michaelslamet, 1. I have two files 1 with .msi and 2nd with _x64.msi 2. Both the files are placed in some folder, for that i have defined the path in a variable $sPath. 3. Now as i have written in the above code i used Local $sFileList = _FileListToArray($sPath) 4. From this line of code, i am not sure that at which location of array the .msi file will be and at which location the _x64.msi file will be. i can use $sFileList[1] = "file name1_.msi" $sFileList[2] = "filename2_x64.msi" but ii would be the hard code as i am mentioning the file names here, i do not want to use the file names in the array location, instead i would prefer to use extension i.e. .msi and _x64 which will work for every new file placed at $sPath. i hope it may clear to you. thanks Link to comment Share on other sites More sharing options...
FireFox Posted September 23, 2013 Share Posted September 23, 2013 Please wait at least 24H before bumping a topic. Link to comment Share on other sites More sharing options...
michaelslamet Posted September 23, 2013 Share Posted September 23, 2013 Hi Vis, Why do you need to declare this in your script? $sFileList[1] = "file name1_.msi" $sFileList[2] = "filename2_x64.msi" As you said, you dont want to hardcode it. If you need to run it, you can just do something like this: Run($sFileList[1]) Link to comment Share on other sites More sharing options...
michaelslamet Posted September 23, 2013 Share Posted September 23, 2013 Melba's >RecFileListToArray might be give you some ideas you need Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted September 23, 2013 Share Posted September 23, 2013 I think he means that the filenames might be different but the extentions will remain the same. This might require some RegExp... "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
tirpider Posted September 23, 2013 Share Posted September 23, 2013 (edited) _FileListToArray can accept wildcards. Local $sPath = "filename*.msi" Would catch both your given examples. -edit Well, not both.. I didn't see the space. But a bit of tinkering with the wildcards (they are the same ones DOS or Windows accepts) should be able to catch them. -edit2 ...and I think I misunderstood what you are doing. It looks like you are trying to change the extension of the file from .64msi to .msi? Edited September 23, 2013 by tirpider Link to comment Share on other sites More sharing options...
DatMCEyeBall Posted September 23, 2013 Share Posted September 23, 2013 You could do 2 calls to _FileListToArray, to find both files. "Just be fred, all we gotta do, just be fred." -Vocaliod "That is a Hadouken. A KAMEHAMEHA would have taken him 13 days and 54 episodes to form." - Roden Hoxha @tabhooked Clock made of cursors ♣ Desktop Widgets ♣ Water Simulation Link to comment Share on other sites More sharing options...
shiv Posted September 23, 2013 Author Share Posted September 23, 2013 Hi DatMCEyeBall, You are right Link to comment Share on other sites More sharing options...
shiv Posted September 23, 2013 Author Share Posted September 23, 2013 Hi Vis, Why do you need to declare this in your script? $sFileList[1] = "file name1_.msi" $sFileList[2] = "filename2_x64.msi" As you said, you dont want to hardcode it. If you need to run it, you can just do something like this: Run($sFileList[1]) Hi michaelslamet, We are not sure that which file is located at $sFileList[1] it mat be .msi or .64msi. Link to comment Share on other sites More sharing options...
JohnOne Posted September 23, 2013 Share Posted September 23, 2013 Very confusing this thread. StringInStr($array[n],"x64") will tell you one from the other. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted September 23, 2013 Moderators Share Posted September 23, 2013 vis,This works for me:#include <Array.au3> ; Only for display #include <File.au3> $sPath = @ScriptDir ; List all .msi files $aList = _FileListToArray($sPath, "*.msi", 1) ; Now look for a matching x64.msi file For $i = 1 To $aList[0] ; Trim the .ext $sRoot = StringTrimRight($aList[$i], 4) ; And see if there is a matching x64 file If FileExists($sPath & "\" & $sRoot & "x64.msi") Then ; If so then create array Local $aRet[3] = [2, $aList[$i], $sRoot & "x64.msi"] ; No point in looking further ExitLoop EndIf Next ; Display the result _ArrayDisplay($aList)Now you always get the .msi file in element [1] and the x64.msi in element [2]. Good enough? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
shiv Posted September 24, 2013 Author Share Posted September 24, 2013 Thanks to All, for helping , and thank you very much Melba23, its working. you are really a genius 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