technical architecture.

Tag: utility

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...

Animoto..

by on Dec.05, 2008, under Portfolio, video

I was asked to build a few basic slideshow type animations to play in the background at a company event, which is all well and good, except “we dont want to spend any time on this, but can you make them look good?” Thanks!

So in comes a fun little toy of a site Animoto. You simply feed it a selection of images and a music track and it does a little magic in the background for you, and out comes a fun little ‘slideshow’ here’s a sample of one of the animations it outputs:

Nifty eh? If there was a way to feasibly add video clips in, and per slide titles, then this could be a pretty badass little toy to use as a baseline.

Leave a Comment :, , more...

Maxscript: Grid by Name

by on Nov.07, 2008, under Architecture, maxscript, utility

Here’s a useful one i made in 2003, one of my first scripts actually! posting it up because i find myself using it ~60 times a day on this current project with curved/angled bits all over it!

A Helper dialog to speed up working with custom Grids. Helps immensely in the workflow of angular modeling (read: silly modern architecture) when combined with a hotkey to create grid and autogrid >:)

Basics: It populates the dialog with all current grids in the scene, including the HomeGrid. you can double click on any grid to activate that, also has buttons to change the view to match the grid, and to select the current active grid. also includes a cycle of the Toolmodes (View/World/Parent/Screen/Local/Gimbal/Grid)

— if there are no grids in the scene, then toggle between the toolmodes
— if there is just 1 grid in the scene, toggle between it and the Home Grid
— if there are grids in the scene, open the window
— if there are grids in the scene and the window is already open, toggle between the grids

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!