How can I bulk rename files in Windows to prepend the parent folder’s name using PowerShell? [duplicate]

I have a large directory structure containing thousands of images organized by project folders (e.g., Project_A/image1.jpg, Project_B/image1.jpg). I need to safely rename all these files so they include the parent directory’s name, changing image1.jpg to Project_A_image1.jpg.