import tkinter as tk
from tkinter import filedialog
import sys

def get_folder_path():
    """Creates a Tkinter root window, shows a folder selection dialog, and returns the path."""
    root = tk.Tk()
    root.withdraw()  # Hide the main tkinter window
    # Make sure the dialog appears on top of other windows
    root.attributes('-topmost', True)
    # Open the dialog to select a directory
    folder_path = filedialog.askdirectory(title="Select Folder Containing Your Files")
    root.destroy() # Clean up the Tkinter window
    return folder_path

if __name__ == "__main__":
    selected_path = get_folder_path()
    if selected_path: # If a path was selected (user didn't cancel)
        print(selected_path) # Print the path to standard output
    sys.exit(0) # Exit successfully
