Batch convert from .dxf to .ai

I have a large number of files exported from a nesting program. Unfortunately they where in a .dxf format that Illustrator can not read. I have searched the forum and found a script (by jeff_hammond) for converting .stp to .obj.

I foolishly thought it would as simple as exchanging .stp to .dxf and .obj to . ai. But that does not seem to be the case. Looking in the command window it seems like it is looking for the correct filename but changed the extension to .3dm. Since nothing is imported it has nothing to save.

any help would be greatly appreciated, since I never programmed any rhinoscript so I am just guessing what could be wrong. Maybe it is something in Mac OS that I missed?

Here is the script (the FilePath has to be changed):

import rhinoscriptsyntax as rs
import os.path

def BatchSaveAs():

folder = "/EgenKonstNow/2019_PixelFamily/0_SheetsNewDxf"
saveFolder = "/EgenKonstNow/2019_PixelFamily/0_SheetsNewAi"

for filename in os.listdir(folder):
    if filename.endswith(".dxf"):
        fullpath = os.path.join(folder,filename).lower()
        rs.Command("-Import {} _Enter".format(fullpath))
        comm="_-ExportAll "
        rs.Command(comm + chr(34) + saveFolder + "/" + filename + ".ai" + chr(34)  + " _Enter" + " _Enter")
        rs.Command("Delete")

BatchSaveAs()

Hello - this appears to work here - the result blobs the extensions together, so I get “XXX.dxf.ai” but the file is written. ExportAll is not a command however… use Export. Jeff may have an alias or something.

-Pascal

I found the problem: there was spaces in the filenames and that messed it up.