Apple Script: File Renaming

I have a folder with several subfolders. Each subfolder contains several images. I want to rename the images in each subfolder to folder_name & "_" & file_name, meaning I want to add the folder name to the image file name. Subsequently I want to move all images from the subfolders to the main folder and delete the subfolders.

I have the image of my script attached. It returns the attached error message. Who can help me ?

The folder I used is on my desktop and I have writing permissions for the folder when I go to "Get Info". That's why I am wondering.

Please don’t post a picture of a script, post the actual script - most aren’t going to bother typing it in.

The main issue I see is that you are using statements of the form set someVariable to item x, which isn’t working the way you think it does.

Apple Script: File Renaming
 
 
Q