I created an AppleScript to update metadata based on a filename. It works fine. I'd like to modify my script so it automatically loops through all files in a folder rather running it for each file. Any ideas how to do that?
For reference, here is my script:
For reference, here is my script:
AppleScript:
-- Set the file path of the video file
set videoFile to choose file with prompt "Choose a video file to update the 'date created' attribute for:"
-- Get the POSIX path of the video file
set videoFilePath to POSIX path of videoFile
-- Get the filename and extension of the video file
set {filename, filenameExtension} to {name, name extension} of (info for videoFilePath without size)
-- Extract the date from the filename
set AppleScript's text item delimiters to {"-", " ", ";", "."}
set filenameItems to text items of filename
set yearText to item 2 of filenameItems
set monthText to item 3 of filenameItems
set dayText to item 4 of filenameItems
set h to item 5 of filenameItems
set m to item 6 of filenameItems
set s to item 7 of filenameItems
-- Convert the date text to a date object
set newCreateDate to monthText & "/" & dayText & "/" & yearText & " " & h & ":" & m & ":" & s
-- Use the "SetFile" command-line tool to change the "date created" attribute
do shell script "/usr/bin/SetFile -d '" & (newCreateDate as string) & "' " & quoted form of videoFilePath
-- Display a dialog box to confirm the update
display dialog "The 'date created' attribute of the video file has been updated." buttons {"OK"} default button 1