I’m trying to write a batch open and save script in Python to run on a Mac. I’d like it to open and saveas (or export) files automatically without input from the user. The best I can get it to do is bring up the open file dialog box. At that point the user has to select a file to open and hit enter. The Command() function is supposed to be able to take an argument specifying the file path but this doesn’t seem to work on a Mac. Does anybody have any ideas?
`import rhinoscriptsyntax as rs
import os
def BatchSaveAs():
#Get folders
folder = rs.BrowseForFolder(message = "Select folder to process")
if not folder: return
saveFolder=rs.BrowseForFolder(message = "Select folder to save files")
if not saveFolder: return
found = False ; counter = 0 ;
for filename in os.listdir(folder):
if filename.endswith(".STEP"):
found = True ; counter += 1
fullpath = os.path.join(folder,filename).lower()
rs.EnableRedraw(False)
#Close the current file
rs.DocumentModified(False)
rs.Command("_-New _None",False)
#Open file to convert
rs.Command ("_-Open " + folder + "_Enter")
comm="_-SaveAs"
rs.Command(comm + chr(34) + saveFolder + chr(34) + ".3dm" + "_Enter")
if not found:
print "No .STEP files found in selected folder!"
else:
print "{} files converted to 3dm format".format(counter)
#open a blank document to finish
rs.DocumentModified(False)
rs.Command("_-New _None",False)
rs.EnableRedraw(True)
BatchSaveAs()