Sims 3 expansion install helper

View previous topic View next topic Go down

Sims 3 expansion install helper

Post by chrixian on Wed 29 Jan 2014, 14:14

UPDATE 1/31/2014: The information contained in this post may still be of use but I recommend using the script in the next post instead.

After I downloaded the Sims 3 and all expansions, I found the "The Sims 3 Mac Installation Guide" very helpful and following it's instructions led to a working installation of the game along with the first expansion ... but not being able to launch the installer directly from the folder I had unpacked everything to was pretty annoying and the process of manually creating a disk image for each remaining expansion and then having to copy the files to that volume wasn't something I looked forward to doing. 

There was no reason symbolic links shouldn't work... so I tried it and it worked as expected and there was no reason I couldn't automate the whole thing so that I could just drag and drop an archive on to a script and have it extract, create a disk image, mount it, and create the symbolic links for me. So how can you do this too?

Note: First let me say, if you can barely operate your computer this may not be for you and you should stick to the PDF instructions... I'm just offering this as a way to make things easier for people capable.

Instructions

Requirements: StuffIt Expander

  • Open "AppleScript Editor.app" found in /Applications/Utilities
  • Create a new document and paste the code contained in the spoiler below

AppleScript (Click To View):
on open input
  tell application "Finder"
    set file_name to (name of (input as alias))
    set file_ext to (name extension of (input as alias))
    set file_container to (container of (input as alias)) as alias
    set file_base to text 1 thru ((offset of "." & file_ext in file_name) - 1) of file_name
    set dmg_path to ((POSIX path of file_container) & file_base & ".dmg")
    set ss_make_image to "hdiutil create -size 5M -layout 'UNIVERSAL CD' -type UDIF -fs 'Journaled HFS+' -volname '" & file_base & "' -attach " & quoted form of dmg_path
    set image_volume to quoted form of ("/Volumes/" & file_base)
  end tell
  tell application "StuffIt Expander"
    launch
    with timeout of 600 seconds --10 minutes should be enough time to extract large files... increase if needed.
      set expanded_file to expand (input as alias) to file_container create enclosing folder always
    end timeout
    quit
  end tell
  
  set dest to POSIX path of expanded_file
  set ss_make_links to "ln -s " & (quoted form of dest) & "* " & image_volume
  
  do shell script ss_make_image
  do shell script ss_make_links
  do shell script "open " & quoted form of ("/Volumes/" & file_base)
  
end open

  • After pasting click the "Compile" button to verify you've copied and pasted correctly... ("Compile" does nothing but verify the syntax of the code, if all is correct it will colorize the script code... if not it will display an error dialog. If you get the error dialog: well done, you can give up now.)
  • Select Save... from the File menu and select "Application" from the "File Format" drop down box. 
  • Name it whatever you want and save it wherever you want (but a good place for it would be the directory with the expansion .rar files you want to install).
  • You're done.

So for example sake let's say you saved the script application as "SimsExpansionHelper.app" and it's in the same folder as "The Sims 3 - University Life.rar". 

If you drag and drop "The Sims 3 - University Life.rar" on to "SimsExpansionHelper.app", StuffIt will extract the contents to a folder called "The Sims 3 - University Life.rar Folder" ... a small (5mb) disk image named "The Sims 3 - University Life.dmg" will be created in the original folder and automatically mounted... symbolic links for all the files in "The Sims 3 - University Life.rar Folder" will be created on the mounted disk volume... and finally the mounted disk will automatically be opened.

At that point double click the installer app and proceed as "The Sims 3 Mac Installation Guide" instructed you. 

When you're done installing you can unmount the volume by right clicking in it's finder window and "eject" it.

Some things worth noting

  1. Because it uses an "on open" handler you can't run the script from the AppleScript Editor and has to be saved as an application.
  2. The script is small and straight-forward and contains no try statements to catch/handle errors. If an error occurs (somehow) it will inform you in a dialog box and you can probably figure out the problem via google.
  3. The default script timeout period is only 1 minute... some of the expansions are nearly 7 gigs and took me longer than a minute to extract so the timeout was increased to 10 minutes. If this (for some reason) isn't enough for your computer you can find the line "with timeout of 600 seconds" and increase it (you'll need to re-save the script application).
  4. An error will occur if the dmg file for that particular .rar file exists already (i.e. if you drag and drop a .rar twice) ... You'll need to delete that .dmg file first.


If you have any questions you can try asking here. Or google.

Cheers,

chrixian

EDIT: I made a new script that is basically the same as above except you drag and drop the already extracted folder on to the .app and the disk image and symbolic links are created for you... It proved less error prone since the AppleScript support in these archive programs leaves much to be desired.. I'll try to get it posted later/tomorrow when I'm home.

chrixian
Beginner
Beginner

Posts : 2
Points : 1309
Reputation : 0
Join date : 2014-01-28

View user profile

Back to top Go down

Re: Sims 3 expansion install helper

Post by chrixian on Fri 31 Jan 2014, 13:34

So it seems like there's an epidemic of poor scripting support in nearly every Mac unarchiving program ... so rather than dealing with inconsistent results when extracting large files it made more sense to just extract manually like usual and drag and drop the folder to create the disk image and symbolic links.

If you want more details on what this is, you can read the previous post.


  • To use it, open the AppleScript Editor (/Applications/Utilities) and create a new document. 
  • Copy and paste the code below. 
  • Save it to the directory with the .rar expansion files and make sure to select "Application" as the File Format.
  • Extract the extension you want to install as you normally would, then drag and drop the folder it extracted everything to onto the .app you just created.
  • After you've dropped the folder on the app you'll have a .dmg, already mounted.. just pick it from the sidebar and double click the installer app as usual. No more having to copy everything to a giant disk image.


Code:
on open input
  tell application "Finder"
    set file_container to (container of (input as alias)) as alias
    set dest to POSIX path of input
    set file_base to (name of (input as alias))
    set dmg_path to ((POSIX path of file_container) & file_base & ".dmg")
    set ss_make_image to "hdiutil create -size 5M -layout 'UNIVERSAL CD' -type UDIF -fs 'Journaled HFS+' -volname '" & file_base & "' -attach " & quoted form of dmg_path
    set image_volume to quoted form of ("/Volumes/" & file_base)
    set ss_make_links to "ln -s " & (quoted form of dest) & "* " & image_volume

    do shell script ss_make_image
    do shell script ss_make_links
  end tell
end open

chrixian
Beginner
Beginner

Posts : 2
Points : 1309
Reputation : 0
Join date : 2014-01-28

View user profile

Back to top Go down

View previous topic View next topic Back to top


Permissions in this forum:
You cannot reply to topics in this forum