I'm kind of a beginner at this, so hopefully this is a simple problem:
I'm trying to create a folder action that will change a file with extension ".jpeg" to ".jpg" when it's put in a given folder.
I set up a folder action to do this, but it's not doing anything for some reason.
here's my script:
on adding folder items to this_folder after receiving added_items
display dialog "hello" as text --> Does not display anything
repeat with theItem in the added_items
tell application "Finder"
set n to name extension of theItem
if n = "jpeg" then
set name extension of theItem to "jpg"
end if
end tell
end repeat
end adding folder items to
Any guesses?
Run application Folder Actions Setup
( /System/Library/CoreServices/Folder Actions Setup.app
) and ensure that Enable Folder Actions
is checked.
In the same application:
Note that folder-action scripts must be saved in one of 2 locations:
/Library/Scripts/Folder Action Scripts
(machine-wide) ~/Library/Scripts/Folder Action Scripts
(user-specific) Also note that you can alternatively use Automator
to create folder actions, but only for files being added (not removed) - this would allow you to use a language other than AppleScript, if desired.
Note, however, that neither mechanism allows you to react to files getting modified .
Incidentally, your debug alert could be written more simply as:
display alert "hello"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.