3

Newbie question. I've created an Applescript that looks at the selected Folder name, copies the last term of the Folder name, and appends that to the beginning of the File Name of the files inside the Folder. I'd like to do choose the Folder automatically instead of manually. I'm sure it's a small change, just not sure how...

tell application "Finder"

    set selected_items to selection

    repeat with this_item in selected_items

        set current_name to name of this_item as text

        set current_extension to name extension of this_item

        set length_extension to length of current_extension

        set name_no_ext to text 1 thru (-length_extension - 2) of current_name

        --set AppleScript's text item delimiters to " "
        set AppleScript's text item delimiters to {"("}


        if (number of text items of name_no_ext > 1) then

            set z to last text item of name_no_ext --get the number at the end of the name before the extension

            --set comments of this_item to z

        end if

        set AppleScript's text item delimiters to ""

    end repeat


    repeat with this_file in (get files of (choose folder))

        set the_name to name of this_file
        set name of this_file to {"(", z, ")", " ", the_name} as string

    end repeat

end tell
  • What do you mean ? "I'd like to do choose the Folder automatically instead of manually." Please elaborate. – CJK Sep 28 '19 at 10:50
  • When I drop the folder onto the application icon, the command "get files of (choose folder)" forces a window to open with the contents of the folder and I need to hit return for the process to continue. The files in the folder get renamed, and then I need to drop the next folder onto the icon to do the same with its contents. I don't want to hit return for the process to continue... – Sherwin Sep 29 '19 at 16:11

You must log in to answer this question.

Browse other questions tagged .