applescript - How to "touch" (update the date of) files in a selection in Finder? -


one thing lot prepare images posting social media, , want "touch" images (change modification date now) via applescript. script below works fine if want drag files applescript app, want script "touches selected in finder" without being run in "on open" loop. (this can run time keyboard maestro, best tool mac users since multifinder.)

every attempt simple set selection, loop through selection, etc. causes errors reason, because finder can't info of file in selection, or something. can possibly suggestion something?

the original script

on open these_items     repeat 1 count of these_items         set this_item (item of these_items)         set item_info info this_item         if folder of item_info true             process_folder(this_item)         else             process_item(this_item)         end if     end repeat end open  -- sub-routine processes folders  on process_folder(this_folder)     shell script "touch \"" & posix path of this_folder & "\""     set these_items list folder this_folder without invisibles     repeat 1 count of these_items         set this_item alias ((this_folder text) & ¬             (item of these_items))         set item_info info this_item         if folder of item_info true             process_folder(this_item)         else             process_item(this_item)         end if     end repeat end process_folder  -- sub-routine processes files  on process_item(this_item)     shell script "touch \"" & posix path of this_item & "\"" end process_item -- rob 

here's simple routine touched items selected in finder.

on touchme()     tell application "finder"         set mylist selection         repeat myfile in mylist             set mytempitem myfile alias             set myposixitem posix path of mytempitem             set myshell "touch \"" & mytempitem & "\""             set result (do shell script myshell administrator privileges)             return result         end repeat     end tell end touchme 

edit: added admin privileges.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -