PDA

View Full Version : Theme Extraction Automation



dsniegocki
12-05-2008, 10:26 AM
Don't know if this has been mentioned before, or if there is some better way that I have totally missed - but here's the way that I automate the extraction of themes that I have downloaded, using a freeware command-line unzip tool, and a VBScript file:


1. Download and install FBZip (freeware unzip utility) from http://www.freebyte.com/fbzip

2. Create a new text document and rename it "ThemeUnzip.vbs"

3. Right-click on the newly created "ThemeUnzip.vbs" file and select "edit"

4. Copy and paste the below script into the "ThemeUnzip.vbs" file

==========================================
Dim objShell, objFSO, colFiles, objFile
dim sZippedThemeRoot, sFBZipRoot, sHSThemeRoot

sZippedThemeRoot = "C:\ZippedUpHS_MAMEThemes"
sFBZipRoot = "C:\Program Files\FreeByteZip"
sHSThemeRoot = "C:\HyperSpin\Media\MAME"

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(sZippedThemeRoot)

Set colFiles = objFolder.Files
For Each objFile in colFiles
objShell.Run """" & sFBZipRoot & "\FBZip"" -e -p """ & sZippedThemeRoot & "\" &

objFile.Name & """ """ & sHSThemeRoot & """"
Next
==========================================

5. Edit the above vb script to reflect the directories of your zipped themes, the location where you installed FBZip, and the directory where your unzipped themes should go (depending on which platform you have zipped themes for, ie MAME)

6. Save the "ThemeUnzip.vbs" file and close it

7. Double-click on the "ThemeUnzip.vbs" file to run the script

From that point on, you can just re-use the "ThemeUnzip.vbs" file to extract new zipped themes that you obtain.

Hope this helps out any of you folks that, like me, might be too lazy to manually one-by-one unzip the themes that others were kind enough to create for everyone.

Dave

dsniegocki
12-05-2008, 10:35 AM
Durn it... meant to post this in the "main" general discussion... my bad.

brian_hoffman
12-05-2008, 12:30 PM
Hmmm... I have winrar... I highlight a bunch of files and say extract here.
Works every time

FatNasty
12-05-2008, 02:38 PM
I use winrar also alot easier and feels safer.

dsniegocki
12-06-2008, 01:31 AM
Thanks guys - I did not have WinRAR and had no idea you could do that. Thanks for the tip!

EVEGames
12-06-2008, 08:21 AM
Thanks for creating and sharing the script, dsniegocki. True, Winrar does the job just fine, but I have a suggestion that would make your script very useful. Sometimes people zip their themes and do not set the correct install paths in the zip. This results in brand new folders being created in the Hyperspin folder tree, usually with the username of the theme creator as the root.
Here's my suggestion for turning this script into something VERY useful. If you could modify it to ONLY extract to folders that ALREADY EXIST, and skip the zips that would otherwise create new folders in the tree, I for one would use this script every time. If it could further output a simple text file telling you if any of the zips were skipped (because of the problem described above), that would be icing on the cake.
Just a suggestion. :)

dsniegocki
12-10-2008, 05:44 AM
I can do you one better... I would have to agree that using WinRAR is a much better option for doing all of the extraction, but the themes that extract to their own subdirectory are a bit cumbersome, as they have to be re-copied.

The below script is intended to be run after my FBZip script, or preferably after performing the WinRAR/right-click/extract method described by others. It will iterate through the root (ie MAME) directory, find any immediate subfolder that isn't one of the "main" ones, and re-copy the contents up one level to their proper place. The erroneous subfolders can then be safely deleted.

Lemme know if this does the trick . . .


===============================
Dim objShell, objFSO, colFolders, objFolder, objSubFolder
Dim sHSThemeRoot
const FolderExclude = "|Images|Sound|Themes|Video|"

sHSThemeRoot = "C:\Program Files\HyperSpin\Media\MAME"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(sHSThemeRoot)
Set objShell = CreateObject("WScript.Shell")

Set colFolders = objFolder.SubFolders
for each objSubFolder in colFolders
if inStr(lcase(FolderExclude), "|" & lcase(objSubFolder.Name) & "|") = 0 then
' loop through this folder, redistribute files to root
objShell.Run "xcopy """ & sHSThemeRoot & "\" & objSubFolder.Name & "\*.*"" """ & sHSThemeRoot & """ /E /Y"
end if
next
===============================

BadBoyBill
12-10-2008, 06:31 AM
No themes should be approved that extract to their own folder, it would benefit the community much if these themes are reported if they slip through the cracks. It is meant to be a simple extract with winrar or 7zip or whatever you use.

EVEGames
12-11-2008, 05:33 AM
No themes should be approved that extract to their own folder, it would benefit the community much if these themes are reported if they slip through the cracks. It is meant to be a simple extract with winrar or 7zip or whatever you use.

They should not be approved BBB, but it still can happen, and does. I still find myself downloading a new batch of 30 or 40 Themes every few weeks and opening up each and every archive to glance at the extract paths and make sure they are not hosed. The last batch I did (a few weeks ago), one was hosed. I don't remember which. I did PM one of the moderators at the time to report it. Anyway, I've just learned not to assume the paths are right.

dsniegocki, if that script works, then as far as I'm concerned it's worth it's weight in gold. How much does a script weigh, I don't know, but it's GOLD. Thanks given just for the effort alone, thanks for contributing to the community, and I'm glad to see we have another knowledgeable VBscript writer willing to whip up some custom stuff to benefit the community.