(Feb-26-2019, 07:30 PM)deep_logic Wrote: I have autocad batch print 50 files to adobe pdf. The problem is the default filename will add "Layout (1) .pdf" at the end of the filename.How dos the raw filename look?
Let say as you say just add
fooLayout (1).pdf
hello worldLayout (2).pdf
import os import re for file_name in os.listdir('.'): if file_name.endswith('.pdf'): new_name = re.sub(r'L.*\)', '', file_name) # Always test print before doing chages to files print(file_name, new_name) #os.rename(file_name, new_name)
Output:foo.pdf
hello world.pdf