algorithmic modeling for Rhino
Hello,
I'm exporting ViewCaptures from a GHPython script, and would like to check if a picture with the same name already exists so as not to overwrite anything.
I'm looking for something like "rs.IsFile()". If "picture" exists, it should try "picture_1", if not "picture_2" and so on:
path = "C:\Users\MyName\Desktop\MyFolder\"
filename = "picture"
if rs.IsFile(path+filename): newname = filename+"_1"
else: newname = filename
count = 0
while rs.IsFile(path+newname):
Tags:
you can try os module for that
import os
os.path.isfile(full file path)
Ah, easy!
Thanks.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by