# How to reopen folder select dialog (probbably by clearing string property)

I want to create a function that:

• checks if a file test.txt is in a location from filepath variable
• if it is not the displays the dialog again

I've got this:

class FileBrowserOperator(bpy.types.Operator):

bl_idname = "object.file_browser_operator"
bl_label = "File browser Operator"

filepath = bpy.props.StringProperty(subtype="DIR_PATH")

def execute(self, context):
while not os.path.isfile(
context.scene.content_path + '/test.txt'):

context.scene.content_path = self.filepath
print("Path:")
print(context.scene.content_path)
return {'FINISHED'}
[...]


But it shows the dialog only once. I assume, that at the beginning of the loop I've got to clear this value somehow, but I do not know how. Thank You in advence

I'd suggest just recall the operator, eg the operator file export template operator_file_export.py Used a directory property for a folder path, to keep filepath as a file path (usual usage).

class ExportSomeData(Operator, ExportHelper):
"""This appears in the tooltip of the operator and in the generated docs"""
bl_idname = "export_test.some_data"  # important since its how bpy.ops.import_test.some_data is constructed
bl_label = "Export Some Data"

# ExportHelper mixin class uses this
filename_ext = ".txt"

filter_glob = StringProperty(
default="*.txt",
options={'HIDDEN'},
maxlen=255,  # Max internal buffer length, longer would be clamped.
)

directory = StringProperty(subtype='DIR_PATH')

def execute(self, context):
if os.path.isfile(os.path.join(self.directory, "test.txt")):
return {'FINISHED'}
else:
return bpy.ops.export_test.some_data('INVOKE_DEFAULT')