technical architecture.

Tag: asset management

Recursive file size listing output to excel

by on Dec.30, 2009, under Admin, Batching, Scripting, vbscript

Today I had to find all JPG files over a certain size in a large directory tree of a few thousand images, to find some poorly compressed jpg’s, fix the compression, and replace them on a website. Todays cavaet, the CMS is pretty weak and only lets you update 1 image at a time, so you can’t just blindly resave everything and reupload, todays Second cavaet, I dont have server level access to said website, so all the normal automated ways are out of luck.

joy.

So I found a little snip of code online, and threw a pretty simple hack job together to narrow the scope some. (PS: If you do end up doing any vbscript, I’d suggest VbsEdit for an IDE)

Anyway! the code:

It searches through a directory tree of your choosing
for any file matching the filetype: “jpg”
that is above a size threshold: fileSizeThreshold (In this case, 2kb.. so essentially everything)
and outputs it into an excell sheet with full path and size information
so that you can easily Sort, Filter, Delegate, or use as data for further automating!

' // **************************************
' //    ComputerHighGuys recursive search
' //     
' //    Date Created: 20 Aug 07
' //	http://www.tek-tips.com/faqs.cfm?fid=6716
' //
' //	Adjusted to a jpg file search and 
' //	added excel output for easy sorting/filtering
' //	
' // **************************************
 
' // If we'd like to save the output into an excel sheet
WriteExcel = "True"
 
Dim objexcel
excelRow=2
 
' // value the filesize needs to exceed to be visible in the output
fileSizeThreshold=2
 
If WriteExcel = "True" Then
	' // Create the Excel sheet to drop the information into
	Set objExcel = createobject("Excel.application")   
	objexcel.Workbooks.add
	objexcel.Cells(1, 1).Value = "Folder Name"
	objexcel.Cells(1, 2).Value = "Filename"
	objexcel.Cells(1, 3).Value = "Filesize"
	objexcel.Cells(1, 4).Value = "Filesize Unit"
	objexcel.Visible = True
	Wscript.Sleep 300
End If
 
' // Directory to search
searchDir = "C:\"
 
set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(searchDir)
Set colFiles = objFolder.Files
 
' // Launch the function
ScanSubFolders(objFolder)
 
' // recursive function that will search through all subfolders for a specified
' // filetype and output some information about the files to an Excel Sheel
Sub scanSubFolders(objFolder)
	' // Grab sub folders    
    Set colFolders = objFolder.SubFolders
 
    For Each objSubFolder In colFolders
 
    	' // the files to search
        Set colFiles = objSubFolder.Files
        For Each objFile in colFiles
 
            ' // the extension of the filetype to search for  
            If lcase(Right(objFile.Name,3)) = "jpg" Then
 
                ' // Getting File size in KB
                If round(objFile.Size/1024,1) > fileSizeThreshold Then
 
                	' // echo the files to the console
                	WScript.Echo objSubFolder.Path & "  " & objFile.Name & "  " & round(objFile.Size/1024,1)  & "KB"
 
					' // write various shit to excel~                    
                    If WriteExcel = "True" then
                        wscript.Echo objSubFolder.Path & "  " & objFile.Name & "  " & round(objFile.Size/1024,1)  & "KB"
                    	objexcel.Cells(excelRow, 1).Value = objSubFolder.Path
    					objexcel.Cells(excelRow, 2).Value = objFile.Name
    					objexcel.Cells(excelRow, 3).Value =  round(objFile.Size/1024,1)
    					objexcel.Cells(excelRow, 4).Value =  "KB" 
    					excelRow=excelRow+1    
                    End If
                End if    
            End If
        Next
        ScanSubFolders(objSubFolder)
    Next
End Sub
2 Comments :, , , , , more...

working :)

by on Oct.04, 2008, under python, utility

yay, all the right clickies work.

9 Comments :, more...

Diving into Python.

by on Sep.28, 2008, under python

So I got a few hours over this last week to start poking my nose into this Python thing that everyone seems so up in arms about. And I must say, its pretty damn neat so far!

from a suggestion on the tech-artists.org forum I took a look into the Wing IDE to help get started and its very very nice. its a bit pricey however, so I’m going to poke through a couple different IDE’s after my trial expires and see what all the fuss is about all around.

So! I decided a good thing to do would be to go for a speedier version of my asset browser maxscript, as in maxscript it takes ~20 seconds to parse through a fair sized directory structure, and I had to build my own caching mechanisms and data structures to even speed that up to 5seconds at startup. Another problem was the generation of the dynamic webpage when you change directory views could take up a few seconds each click also. all this to essentially pass a filename to max? Pssh!

Well, I’ve got a start going in python by using a slight modification of the Lazy Evaluation Directory Treeview sample found on the wxPyWiki. combined with the ThumbnailCtrl from Andrea Gavana. And its blazing fast in terms of thumbnail generation from even very large images and directory structures.!

combine those with the fun examples of using the COM classes to talk to max from Adam, and lets see how this turns out!

pyAssetBrowser.py

pyAssetBrowser.py

Not bad for a night.. Now to finish it off and connect it to max.. someday when i get more free time 😉

Leave a Comment :, , , more...

Maxscript: So Many Assets, so little cataloging.

by on Aug.13, 2008, under maxscript

So, today I took up the fun job of building some sort of asset management tool. so obviously the first thing is to figure out what kind of assets you have so that you can sort them! now we’ve collected many many models over the years, from useful, to complete shite. so the not so fun part becomes to sort through all of these we need to see what they are obviously!

so using Paul’s excellent batching script ‘Batch it Max

combined with a little Thumbnail rendering script i cooked up that will render an Isometric view of the maxfile’s contents, ignore all scene lights, and render with a basic skylight, include a polycount on the render. there are also options in the script whether to use a default skylight lighting scheme, or whether to render the scene using an Ambient Occlusion override material

I made the thumbnail script based partially off of Marc Lorenz’s (also useful) Ambient Occlusion script.

So. the computer behind me is happily cataloging our whole mess.

I wonder if it’ll be done by morning? 🙂

1 Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!