Batch save Python script on a Mac

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()
            #Close the current file
            rs.Command("_-New _None",False)
            #Open file to convert
            rs.Command ("_-Open " + folder + "_Enter")
            rs.Command(comm + chr(34) + saveFolder + chr(34) + ".3dm" + "_Enter")
    if not found:
        print "No .STEP files found in selected folder!"
        print "{} files converted to 3dm format".format(counter)
    #open a blank document to finish
    rs.Command("_-New _None",False)

upon an initial skim, the first problem i see is it appears you’re trying to open a .STEP with rhino.

Rhino can’t open a .StEP file directly… you’d need to import the file into a blank .3DM then save.

I’m using version 5.1 (5B161) and you can open a .STEP file directly with the Open command. What I’d like to do is open a file without the user interface. As it stands, the script will prompt the user for a source and target folder, which is what I want, then it brings up the open dialog box and stops while it waits for the user to select a file and hit enter. My impression is that it’s impossible to get around this manual interaction with the dialog box.

hmm. i did not realize that you could Open a .step until now… my bad.

fwiw, i understand what you’re after… i haven’t tried the script or analyzed it too much… i won’t have time to try to help today… maybe tonight/tmmr
(and even then, i don’t know if i’ll be of much help :wink: )