Post

Replies

Boosts

Views

Activity

Move image into folder "year" and folder "month".
I made an apple script to move images into folders based on it's Year and Month. I use it to archive raw images when I'm done with it. Though it could help others out there. Using the "Folder Actions Setup". It will get the year and month of the file. Create a folder and set the filename to its year, then create another folder in the year folder and set the filename to it's month and move the file into it. property month_index : {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"} on adding folder items to this_folder after receiving these_items #set this_year to the year of (current date) try tell application "Finder" repeat with i from 1 to number of items in these_items set this_item to item i of these_items as alias set item_type to the kind of this_item as string if item_type is not "Folder" then set file_date to the creation date of this_item set file_year to the year of file_date as string set j to the month of file_date as integer set file_month to item j of month_index as string set Done to my move_file(this_folder, file_year, file_month, this_item) else if item_type is "Folder" then exit repeat end if end repeat end tell on error error_message number error_number if error_number is not -128 then display dialog error_message & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end adding folder items to on move_file(main_folder, year_foldername, month_foldername, this_item) try tell application "Finder" set year_folder to my create_folder(main_folder, year_foldername) set month_folder to my create_folder(year_folder, month_foldername) move this_item to the month_folder without replacing end tell on error error_message number error_number if error_number is -15267 then rename_file(month_folder, this_item) else if error_number is not -128 then display dialog error_message & " move file " & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end move_file on create_folder(directory, foldername) try tell application "Finder" if not (exists folder foldername of directory) then make new folder of directory with properties {name:foldername} end if set the sub_folder to (folder foldername of directory) as alias return sub_folder end tell on error error_message number error_number if error_number is not -128 then display dialog error_message & " create_folder " & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end create_folder on rename_file(sub_folder, this_item) try tell application "Finder" set increment to 1 set file_name to the name of this_item set file_extension to the name extension of this_item set old_file to the (file (name of this_item) of folder sub_folder) as alias repeat set trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name set new_name to (the trimmed_name & " " & (increment as string) & "." & file_extension) as string if not (exists document file new_name of the sub_folder) then set name of (document file file_name of sub_folder) to the new_name move document file this_item to the sub_folder exit repeat else set the increment to the increment + 1 end if end repeat end tell on error error_message number error_number if error_number is not -128 then display dialog error_message & " archive_file " & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end rename_file
0
0
66
6d
I want the "Folder" property of a folder not it's class.
I'm trying to set a boolean value to myVariable using the "Folder" property, but the Applescript editor keeps interpreting it as a class. Here is a shorted code. this is part of a bigger code to identify files dropped into a folder and create a new folder which it renames based on the date of the file that is dropped into the folder. Unfortunately, it keeps making folders every time it makes a new folder. Resalting in continuous loop of folders being created and renamed to "2025". The plan is to us an IF condition to prevent the creation of folders when a folder/s are dropped into my folder with my Folder Action. property directory : "Catalina:Users:Username:Desktop:Folder:File.pdf tell application "Finder" set pathname to POSIX path of directory set item_info to the info for directory set myVariable to Folder of item_info return myVariable end tell I noticed the following when I compile the script The color of the "Folder" is blue. I believe this means it's a class. Normally when I call a property, the color turns pink. it does it correctly when I use "set the file_name to the "name" of this_file". I also tried declaring the "Folder" property in brackets "Folder". did not help I noticed the following when I run the script: It returns ---error number -10004 "A privilege violation occurred. When it runs the "info for" command. I gave the Script Editor Full File access, Full Accessibility access and the FolderActionsDispatcher has full Finder access. Can anyone point me in the right direction! What is the cause of the privilege violation or how would I find what the cause is? How do I force the Script Editor to get the "Folder" property of a folder?
1
0
307
Jul ’25
How does one embed/set a ICC profile/color space into an image using apple script?
How do I get an ICC profile into a form I can embed into an image using Apple Script/Image Events? I'm using the form below make new profile with properties {location:"Macintosh HD/Users/user_N/Desktop/sRGB Profile.icc"}" embed this_image with source profile I've also tried setting the color space property of the image. set the color space of this_image to RGB of course there is more to the code but that is just the part I'm having issues with. I get the error message "Image got an error: can't make profile into type profile" and, error "The variable profile is not defined." number -2753 from "profile" What am I missing here, Anyone know?
3
0
1.2k
Apr ’23
Move image into folder "year" and folder "month".
I made an apple script to move images into folders based on it's Year and Month. I use it to archive raw images when I'm done with it. Though it could help others out there. Using the "Folder Actions Setup". It will get the year and month of the file. Create a folder and set the filename to its year, then create another folder in the year folder and set the filename to it's month and move the file into it. property month_index : {"01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"} on adding folder items to this_folder after receiving these_items #set this_year to the year of (current date) try tell application "Finder" repeat with i from 1 to number of items in these_items set this_item to item i of these_items as alias set item_type to the kind of this_item as string if item_type is not "Folder" then set file_date to the creation date of this_item set file_year to the year of file_date as string set j to the month of file_date as integer set file_month to item j of month_index as string set Done to my move_file(this_folder, file_year, file_month, this_item) else if item_type is "Folder" then exit repeat end if end repeat end tell on error error_message number error_number if error_number is not -128 then display dialog error_message & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end adding folder items to on move_file(main_folder, year_foldername, month_foldername, this_item) try tell application "Finder" set year_folder to my create_folder(main_folder, year_foldername) set month_folder to my create_folder(year_folder, month_foldername) move this_item to the month_folder without replacing end tell on error error_message number error_number if error_number is -15267 then rename_file(month_folder, this_item) else if error_number is not -128 then display dialog error_message & " move file " & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end move_file on create_folder(directory, foldername) try tell application "Finder" if not (exists folder foldername of directory) then make new folder of directory with properties {name:foldername} end if set the sub_folder to (folder foldername of directory) as alias return sub_folder end tell on error error_message number error_number if error_number is not -128 then display dialog error_message & " create_folder " & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end create_folder on rename_file(sub_folder, this_item) try tell application "Finder" set increment to 1 set file_name to the name of this_item set file_extension to the name extension of this_item set old_file to the (file (name of this_item) of folder sub_folder) as alias repeat set trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name set new_name to (the trimmed_name & " " & (increment as string) & "." & file_extension) as string if not (exists document file new_name of the sub_folder) then set name of (document file file_name of sub_folder) to the new_name move document file this_item to the sub_folder exit repeat else set the increment to the increment + 1 end if end repeat end tell on error error_message number error_number if error_number is not -128 then display dialog error_message & " archive_file " & error_number buttons {"Cancel"} default button 1 giving up after 120 end if end try end rename_file
Replies
0
Boosts
0
Views
66
Activity
6d
I want the "Folder" property of a folder not it's class.
I'm trying to set a boolean value to myVariable using the "Folder" property, but the Applescript editor keeps interpreting it as a class. Here is a shorted code. this is part of a bigger code to identify files dropped into a folder and create a new folder which it renames based on the date of the file that is dropped into the folder. Unfortunately, it keeps making folders every time it makes a new folder. Resalting in continuous loop of folders being created and renamed to "2025". The plan is to us an IF condition to prevent the creation of folders when a folder/s are dropped into my folder with my Folder Action. property directory : "Catalina:Users:Username:Desktop:Folder:File.pdf tell application "Finder" set pathname to POSIX path of directory set item_info to the info for directory set myVariable to Folder of item_info return myVariable end tell I noticed the following when I compile the script The color of the "Folder" is blue. I believe this means it's a class. Normally when I call a property, the color turns pink. it does it correctly when I use "set the file_name to the "name" of this_file". I also tried declaring the "Folder" property in brackets "Folder". did not help I noticed the following when I run the script: It returns ---error number -10004 "A privilege violation occurred. When it runs the "info for" command. I gave the Script Editor Full File access, Full Accessibility access and the FolderActionsDispatcher has full Finder access. Can anyone point me in the right direction! What is the cause of the privilege violation or how would I find what the cause is? How do I force the Script Editor to get the "Folder" property of a folder?
Replies
1
Boosts
0
Views
307
Activity
Jul ’25
How does one embed/set a ICC profile/color space into an image using apple script?
How do I get an ICC profile into a form I can embed into an image using Apple Script/Image Events? I'm using the form below make new profile with properties {location:"Macintosh HD/Users/user_N/Desktop/sRGB Profile.icc"}" embed this_image with source profile I've also tried setting the color space property of the image. set the color space of this_image to RGB of course there is more to the code but that is just the part I'm having issues with. I get the error message "Image got an error: can't make profile into type profile" and, error "The variable profile is not defined." number -2753 from "profile" What am I missing here, Anyone know?
Replies
3
Boosts
0
Views
1.2k
Activity
Apr ’23