Reduce Mesh - Export OBJ

Hi All,

I am extremely new at scripting and found a script online that does almost everything I am looking for…

The problem is that I need to work through a folder of files, opening each one individually and then reducing the mesh, and then Exporting to OBJ format.

I look at trying to find other script command and combining them, but was unsuccessful!

Can anyone assist with modifying the script below so it will automate the script process through an entire repository:

Option Explicit
'Script written by
'Script copyrighted by
'Script version Friday, March 30, 2012 2:05:45 PM

Call Main()
Dim strMesh, nFaceCount
strMesh = Rhino.GetObject(“Select mesh to reduce”, 32)
If Not IsNull(strMesh) Then
nFaceCount = Rhino.MeshFaceCount(strMesh)
Rhino.ReduceMesh strMesh, nFaceCount * .3
End If
Sub Main()

End Sub

few months ago I found a script here which can convert v5 files into v4 without open them individually. it maybe helps you with this:

! _-RunPythonScript (

import rhinoscriptsyntax as rs
import os

def BatchSaveAsV4():
#Get folders
folder = rs.BrowseForFolder(“Select folder to process”)
if not folder: return

saveFolder=rs.BrowseForFolder("Select folder to save files")
if not saveFolder: return

found = False ; counter=0 ; suffix="-V4"
#Find Rhino files in the folder
for filename in os.listdir(folder):
    if filename.endswith(".3dm"):
        found = True ; counter+=1
        #Close the current file
        rs.Command("_-New _None",False)
        #Open file to convert
        rs.Command ("_-Open " + chr(34) + fullpath + chr(34), False)
        #Save file as a V4 file with suffix            
        comm="_-SaveAs _Version=4 "
        comm+="_SaveSmall=_Yes _GeometryOnly=_No _SavePlugInData=_Yes "
        rs.Command(comm + chr(34) + savepath + suffix + ".3dm" + chr(34), False)
if not found:
    print "No Rhino files found in selected folder!"
    print "{} files converted to V4 format".format(counter)
#open a blank document to finish
rs.Command("_-New _None",False)