Jump to content

MrStreeter

Member
  • Posts

    3
  • Joined

  • Last visited

Posts posted by MrStreeter

  1. 2 minutes ago, vitor said:

    Save your script inside the Workflow with a proper shebang (#!/usr/bin/python3) and call it as an External Script as the Language. Or use /bin/zsh as the Language and call your script with /usr/bin/python3 SCRIPT_NAME. You were never limited by the languages in the dropdown, you can easily use anything on your system.

     

    This is what I ended up doing. Thanks for confirming.

     

    Not sure why i never did it this way to begin with, its a lot easier/nicer to be able to handle a script in an IDE than a text box!

  2. I needed a workflow that put the resized images into a sub folder of the originals, so made the following amendments.

    It can handle multiple file selections within differing directories and place the resize-x folder within the respective directory relative to the original image.

    1. Open the "Process image(s)" AppleScript block in the workflow
    2. Find the following lines in the downloadable version (Lines 27-28)
      			set myPath to this_file
      		end if

      And insert the following after it that will create a new directory next to the file being resized in the format of 'resize-{resize-width}' (resize-500, resize-1024 for example)

              -- Remove the file name from the end of the path string
              set filePath to characters 1 thru -((offset of "/" in (reverse of items of myPath as string)) + 1) of myPath as text
              set fileName to name of (info for myPath)
              -- Create a full path to the folder that we want.
              set resizeFolderName to ((filePath as text) & "/resize-" & (target_width as text) & "/") as text
      
              -- Check for the resize-x folder and create it if not present
              if folderExists(resizeFolderName) then
      			set outputFolder to resizeFolderName
              else
      			set createThisFolder to POSIX file filePath as alias
      
                  tell application "Finder" to make new folder in createThisFolder with properties {name:"resize-" & target_width}
      			set outputFolder to resizeFolderName
              end if

       

    3. Change the following line (Originally on line 38, with the addition of the above, its now on line 60)
       

      save this_image in myPath

      to
       

      save this_image in outputFolder & fileName

       

    4. Add the following function to the end of the file:
       

      on folderExists(theFolder)
          tell application "Finder"
              try
                  set thisFolder to the POSIX path of theFolder
                  set thisFolder to (POSIX file thisFolder) as text
                  -- set thisFolder to theFolder as alias
                  return true
              on error err
                  return false
              end try
          end tell
      end folderExists

       

    Or, if you want the whole script in one thing, its on a Gist here: https://gist.github.com/danstreeter/23fe01074034832fec09c0b633522559

×
×
  • Create New...