Jump to content

yuvi

Member
  • Posts

    2
  • Joined

  • Last visited

Posts posted by yuvi

  1. My file management scheme requires me to add prefixes to the names of files, which are then picked up by Hazel and handled in various ways. My applescript skills are admittedly crude, but here is my workflow (driven by a file action) to prompt the user for a prefix string and then add that string to the names of all the selected files. Right now, the default prefix in the dialog box is "archive-" but that's easily changed from within the simple applescript.

    The workflow is here: http://d.pr/f/bDxq

    But if you just want a peek at my weak applescripting chops, here you go:
     

    on alfred_script(q)
    	set prefixValue to display dialog "Enter prefix string: " default answer "archive-"
    	set AppleScript's text item delimiters to tab
    	set fileList to every text item of q
    	repeat with theFilename in fileList
    		set theFile to POSIX file theFilename
    		tell application "Finder"
    			set fileAlias to theFile as alias
    			set fileName to name of fileAlias
    			set newFilename to (text returned of prefixValue & fileName)
    			set name of file theFile to newFilename
    		end tell
    	end repeat
    end alfred_script

    Enjoy!

×
×
  • Create New...