MHz Posted April 20, 2007 Share Posted April 20, 2007 (edited) Summary:Since the AutoIt Installer already has files within for the Zip users, then a script to extract the files to save the developers the constant need to supply zips through a lot of beta distributions. The script well extract and sort the files and folders into the suitable structure for you and will attempt to zip them up for you, If zipping errors happen, then it should leave the extracted files there for you to copy over if needed to.Drag'n'Drop or use the FileOpenDialog to process the AutoIt Installer.It uses some 7Zip files to do the extracting and zipping.*** Rewritten Script ***Edit:1. Rewritten using FFFF/FFNF to step through and move the files and folders. I think it works well. Perhaps different machines may need more sleep or such. Let me know if it needs attention.2. Now does all work in @TempDir, Structure seems to be as exact as the downloadable zip, IMO. Moving is done inside the same extracted folder to shorten and optimize code.Source Files:Extract_AutoIt_Installer_3_Source.zipCompiled:Extract_AutoIt_Installer_3.zipexpandcollapse popupIf Not $CMDLINE[0] Then $filepath = FileOpenDialog('Locate the AutoIt Installer', @WorkingDir, 'Executable (*.exe)', 1) If @error Then Exit 1 EndIf ElseIf $CMDLINE[0] = 1 And StringRight($CMDLINE[1], 4) = '.exe' Then $filepath = $CMDLINE[1] Else Exit 2 EndIf If @WorkingDir <> @TempDir Then FileChangeDir(@TempDir) EndIf If DirCreate('formats') And DirCreate('codecs') Then FileInstall('7z.exe', @TempDir & '\', 1) FileInstall('formats\nsis.dll', @TempDir & '\formats\', 1) FileInstall('formats\zip.dll', @TempDir & '\formats\', 1) FileInstall('codecs\lzma.dll', @TempDir & '\codecs\', 1) FileInstall('codecs\deflate.dll', @TempDir & '\codecs\', 1) Sleep(500) Else Exit 4 EndIf ProgressOn('', '', 'Extracting files...') $count = 10 ProgressSet($count) $file = StringTrimLeft($filepath, StringInStr($filepath, '\', 0, -1)) $folder = StringTrimRight($file, 4) DirCreate($folder) $exitcode = RunWait(@TempDir & '\7z.exe x -aos "' & $filepath & '" -o"' & $folder & '"', @WorkingDir, @SW_HIDE) Sleep(1000) $count += 10 ProgressSet($count) If Not $exitcode And FileChangeDir($folder) Then ProgressSet($count, 'Sorting files into the correct layout') $handle_file = FileFindFirstFile('*') If $handle_file <> -1 Then While 1 $file_found = FileFindNextFile($handle_file) If @error Then ExitLoop $file_attribute = FileGetAttrib($file_found) If @error Then ContinueLoop If StringInStr($file_attribute, 'D') Then Switch $file_found Case '$PLUGINSDIR', '$WINDIR' If DirRemove($file_found, 1) Then $count += 5 ProgressSet($count) EndIf Case '$_OUTDIR' $count += 5 ProgressSet($count) ContinueLoop Case 'Aut2Exe' ExitLoop Case Else If FileExists($file_found & '\SciTE') Then If DirMove($file_found & '\SciTE', '.', 1) Then $count += 5 ProgressSet($count) EndIf EndIf EndSwitch Sleep(500) EndIf WEnd FileClose($handle_file) If @OSVersion <> 'WIN_NT' And @OSTYPE <> 'WIN32_WINDOWS' Then FileDelete('psapi.dll') EndIf $folder_source = '$_OUTDIR' $handle_file = FileFindFirstFile($folder_source & '\*') If $handle_file <> -1 Then While 1 $file_found = FileFindNextFile($handle_file) If @error Then ExitLoop Switch $file_found Case 'AutoUpdateIt', 'Editors', 'Exe2Aut', 'SQLite', 'v2_to_v3_Converter' If DirMove($folder_source & '\' & $file_found, 'Extras\' & $file_found) Then $count += 5 ProgressSet($count) EndIf Case 'GUI', 'Helpfile' If DirMove($folder_source & '\' & $file_found, 'Examples\' & $file_found) Then $count += 5 ProgressSet($count) EndIf Case 'StandardDll', 'ActiveX' If DirMove($folder_source & '\' & $file_found, 'AutoItX\' & $file_found) Then $count += 5 ProgressSet($count) EndIf EndSwitch Sleep(500) WEnd FileClose($handle_file) DirRemove('$[34]', 1) DirRemove('$_OUTDIR', 1) While FileExists('$[34]') And FileExists('$_OUTDIR') Sleep(500) WEnd EndIf EndIf $count += ((100-$count)/2) ProgressSet($count, 'Zipping Files...') $exitcode = RunWait(@TempDir & '\7z.exe a -tzip "' & $folder & '.zip" *', @WorkingDir, @SW_HIDE) Sleep(1000) ProgressSet(100, 'Almost done') If Not $exitcode Then If FileMove($folder & '.zip', @ScriptDir & '\') Then If FileChangeDir(@TempDir) Then DirRemove($folder, 1) Else DirMove($folder, @ScriptDir & '\' & $folder) EndIf EndIf ProgressOff() _Cleanup() MsgBox(0, @ScriptName, 'Converted to Zip Archive') Else ProgressOff() _Cleanup() MsgBox(0, @ScriptName, 'Extracted to "' & $folder & '" folder') EndIf EndIf Exit Func OnAutoItStart() If WinExists(@ScriptName & '_Interpreter') Then Exit AutoItWinSetTitle(@ScriptName & '_Interpreter') EndFunc Func _Cleanup() If @Compiled Then FileChangeDir(@TempDir) FileDelete('7z.exe') DirRemove('codecs', 1) DirRemove('formats', 1) EndIf EndFunc Edited April 26, 2007 by MHz Link to comment Share on other sites More sharing options...
James Posted April 20, 2007 Share Posted April 20, 2007 Wow, that is awesome. Great Improvements from the other installer. Keep up the good work MHz! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
MHz Posted April 20, 2007 Author Share Posted April 20, 2007 Wow, that is awesome. Great Improvements from the other installer. Keep up the good work MHz! Thanks, but it is not meant to be an improvement but an alternative to using the installer. Some will have a certain setup where using the standard installer is unsuitable. I'm fairly sure the AutoIt Devs would like to not supply a zip if it were not needed with the beta versions for ease. Link to comment Share on other sites More sharing options...
James Posted April 21, 2007 Share Posted April 21, 2007 Ahh right. Well, either way its still awesome! Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
MHz Posted April 21, 2007 Author Share Posted April 21, 2007 Ahh right. Well, either way its still awesome!Thanks, I'll accept that again . I was just being descriptive in my last post of it's purpose . Link to comment Share on other sites More sharing options...
therks Posted April 22, 2007 Share Posted April 22, 2007 Hmm, having some trouble. I run your program, give it the new 3.2.3.6 installer file, and it does it's business, extracts files, etc. Then it says "Extracted to folder" and the only thing left in the folder is a file named "Beta" (no extension) that appears to be a list of AutoIt functions and macros.After a bit of experimenting, here's the problem as near as I can figure it out:- It extracts the files just fine and puts them in a "temp" folder.- Then you have all those DirMove()'s which are supposed to move all the folders within the "temp" folder into the "Beta" folder. Well the "Beta" folder doesn't exist, and it doesn't get created at any point in the script, and as such all those DirMove()'s fail...- Then you DirRemove() the "temp" folder...- Well, as you can guess by this point, since nothing got moved out of the "temp" folder, everything is still in it, and when you DirRemove() it, it all gets erased.So the script pulls everything out of the setup file, then just deletes it all. I still haven't figured out why it leaves me one file called "Beta" though. That file appears to be the "au3check.dat". I'm thinking it has something to do with the FileMove('temp\*.*', 'Beta\') line, although I wasn't able to reproduce the results.I ended up just commenting out the DirRemove('temp', 1) and then manually sorting out the files.Thanks for the script though, as without it I wouldn't have known how to extract the files from the setup anyway! My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
MHz Posted April 22, 2007 Author Share Posted April 22, 2007 Hmm, having some trouble. I run your program, give it the new 3.2.3.6 installer file, and it does it's business, extracts files, etc. Then it says "Extracted to folder" and the only thing left in the folder is a file named "Beta" (no extension) that appears to be a list of AutoIt functions and macros.Odd, I have not resulted in an extensionless called Beta yet in testing.After a bit of experimenting, here's the problem as near as I can figure it out:- It extracts the files just fine and puts them in a "temp" folder.- Then you have all those DirMove()'s which are supposed to move all the folders within the "temp" folder into the "Beta" folder. Well the "Beta" folder doesn't exist, and it doesn't get created at any point in the script, and as such all those DirMove()'s fail...- Then you DirRemove() the "temp" folder...- Well, as you can guess by this point, since nothing got moved out of the "temp" folder, everything is still in it, and when you DirRemove() it, it all gets erased.The 1st DirMove should create the Beta folder unless something odd is at play at your end. It gets created here. I think it boils down to timing as AutoIt moves along quicker then what the file system does.So the script pulls everything out of the setup file, then just deletes it all. I still haven't figured out why it leaves me one file called "Beta" though. That file appears to be the "au3check.dat". I'm thinking it has something to do with the FileMove('temp\*.*', 'Beta\') line, although I wasn't able to reproduce the results.I ended up just commenting out the DirRemove('temp', 1) and then manually sorting out the files.Thanks for the script though, as without it I wouldn't have known how to extract the files from the setup anyway!Thanks. The wildcard move could be a issue with timing if AutoIt does not wait long enough. I have made some changes to slow down the script in the 1st post. Hopefully it may help to make it work for you. I added Sleeps and create the beta folder to avoid the beta file with no extension result. Let me know how it works for you. Link to comment Share on other sites More sharing options...
GEOSoft Posted April 22, 2007 Share Posted April 22, 2007 @MHz I had simiar timing isues with Project Express when deleting a Project. Often 1 folder would get left behind. The soution was DirRemove("Pathh", 1) Whie FileExists("Path") Sleep(1) Wend HTH George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
MHz Posted April 22, 2007 Author Share Posted April 22, 2007 @MHzI had simiar timing isues with Project Express when deleting a Project. Often 1 folder would get left behind.The soution wasDirRemove("Pathh", 1) Whie FileExists("Path") Sleep(1)WendHTHThanks for the tip.I have done a rewrite using FFFF & FFNF and seems to work better. I get a zip every time so must hold some hope for success. Unleashing into the wild will test it out indeed. Link to comment Share on other sites More sharing options...
therks Posted April 22, 2007 Share Posted April 22, 2007 (edited) The 1st DirMove should create the Beta folder unless something odd is at play at your end. It gets created here. I think it boils down to timing as AutoIt moves along quicker then what the file system does. For me, if I try to move a folder within a folder, to a folder that doesn't exist, the new folder never gets created. For example, I created a folder, named it Folder1, and within that folder made another folder, called it Subfolder. Then I ran this: DirMove('Folder1\Subfolder', 'Folder2\Subfolder') And it returned 0, and nothing happened. If I create Folder2 first, then it works fine, but otherwise meh. But anyway! Your new script works fine, very slick. Awesome job. The devs might do well to just release this into the downloads directory, and stop supplying the .zip files. One thing I would be wary of though is line 19, DirRemove($precheck[$i]). It's possible some people might run this script from their root AutoIt folder, or any folder that might happen to have some of the folders in $precheck in them, and you'll get some very angry people if suddenly their folders start disappearing. I would just stick to the If FileExists Then Exit process you had before. Or maybe have all the work get done in the @TempDir. Then it would be virtually invisible to the user, and anything that disappears out of there shouldn't really be worried about. ANYWAY all nitpicks aside this is a very cool program you've written up MHz. Thanks a bunch. *Edit: Oops, scratch that last part, I just remembered that DirRemove without the extra parameter will not erase non-empty folders. I still like the idea of doing the work in @TempDir though. Edited April 22, 2007 by Saunders My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
NELyon Posted April 23, 2007 Share Posted April 23, 2007 (edited) .But anyway! Your new script works fine, very slick. Awesome job. The devs might do well to just release this into the downloads directory, and stop supplying the .zip files.you wanna kill Mr.Zippy-Zip??? Lol, but anyway, Very nice. Saves some time EDIT: Ugh... i cannot live without Mr.Cry-ie-smilie Edited April 23, 2007 by Senton-Bomb Link to comment Share on other sites More sharing options...
MHz Posted April 23, 2007 Author Share Posted April 23, 2007 ANYWAY all nitpicks aside this is a very cool program you've written up MHz. Thanks a bunch.*Edit: Oops, scratch that last part, I just remembered that DirRemove without the extra parameter will not erase non-empty folders. I still like the idea of doing the work in @TempDir though. Thanks. Yeah, the DirRemove was in case of empty folders to save a restart of script. @Tempdir could reside on a different drive, and if so, then a copy and delete operation would happen rather then a move which is done only in the file table when done on the same drive.Anyway, glad it is working for you. That is what matters in the end. @Senton-BombIf Mr. Zippy is a pain. Then perhaps he deserves to be knocked off, lol. That is why we use AutoIt for in the 1st place, to make life easier and better. Link to comment Share on other sites More sharing options...
MHz Posted April 26, 2007 Author Share Posted April 26, 2007 I have had another look at the script to get it finalized. All work done in @TempDir as Saunders had asked for. I got another look at a downloaded zip to refresh me of the layout and consider that I have replicated it. Testing seems fine to me so I will let the community to use it now and see how it shapes up. 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