EzDev.org

automator interview questions

Top 15 automator interview questions

9564 Jobs openings for automator


OS X (Unix) shell command: possible to get last opened date of file?

when you use the following command

find /Users/someUser/someFolder/* -type f -mtime +90

you'll get all the files that have a modification date that is bigger than 90 days. If you open however the file properties in the Finder on OS X for instance there is also a "Last opened" date. Is there a possibility to get all files with a last opened date bigger some treshold like the example above?? Sadly there's no "-otime" :)

Also on Automator you there's no filter for the last open time but just for modified time and created time...

Thanks a lot


Source: (StackOverflow)

What is the best way to make Calculate SHA1 as a context menu option in Mac OS X?

In order to calculate the SHA1 checksum of a downloaded file, I could type

/usr/bin/openssl sha1

in Terminal and then drag there the file which I want check. To make it simpler, one could enable a Context Menu item for this action.

What is the best way to create such item in Mac OS X 10.6? A detailed answer is appreciated, because I don't have good experience with AppleScript, etc.


Step by step

  1. Open Automator
  2. Create new service
  3. Choose to receive selected Files and Folders in Finder
  4. Add action Run Shell Script where your bash command is /usr/bin/openssl sha1 "$@" and you pass input as arguments

How can I get the output? Preferably in a Growl pop-up or a message window/dialog.


Source: (StackOverflow)

Mac OS: How can I launch the iTerm terminal, with a specific profile, from Automator or AppleScript?

I'm trying to assign a global keyboard shortcut that will launch a new window of iTerm, with a specific profile. (I managed to do this to launch a new Chrome window with Automator and AppleScript, but this is proving more difficult)

This would be equivalent to activating iTerm, and in the top menu select Profiles -> "my profile", with "alt" or "option" pressed, so it'll open in a new window, not a new tab in the current window.

Any ideas how to do this with either Automator or AppleScript?

In case it's relevant, I have Mac OS Mountain Lion

(Sorry if this is an absolute noob question, I just moved from Windows to Mac, and I'm trying to optimize the things I do all the time)

Thank you!


Source: (StackOverflow)

How do I parse file paths separated by a space in a string?

Background: I am working in Automator on a wrapper to a command line utility. I need a way to separate an arbitrary number of file paths delimited by a single space from a single string, so that I may remove all but the first file path to pass to the program.

Example input string:

/Users/bobby/diddy dum/ding.mp4 /Users/jimmy/gone mia/come back jimmy.mp3 ...

Desired output:

/Users/bobby/diddy dum/ding.mp4

Part of the problem is the inflexibility on the Automator end of things. I'm using an Automator action which returns unescaped POSIX filepaths delimited by a space (or comma). This is unfortunate because: 1. I cannot ensure file/folder names will not contain either a space or comma, and 2. the only inadmissible character in Mac OS X filenames (as far as I can tell) is :. There are options which allow me to enclose the file paths in double or single quotes, or angle brackets. The program itself accepts the argument of the aforementioned input string, so there must be a way of separating the paths. I just do not have a keen enough eye to see how to do it with sed or awk.

At first I thought I'll just use sed to replace every [space]/ with [newline]/ and then trim all but the first line, but that leaves the loophole open for folders whose names end with a space. If I use the comma delimiter, the same happens, just for a comma instead. If I encapsulate in double or single quotation marks, I am opening another can of worms for filenames with those characters.

The image/link is the relevant part of my Automator workflow.

-- UPDATE --

I was able to achieve what I wanted in a rather roundabout way. It's hardly elegant but here is working generalized code:

path="/Users/bobby/diddy dum/ding.mp4 /Users/jimmy/gone mia/come back jimmy.mp3"

# using colon because it's an inadmissible Mac OS X
# filename character, perfect for separating
# also, unlike [space], multiple colons do not collapse
IFS=:

# replace all spaces with colons
colpath=$(echo "$path" | sed 's/ /:/g')

# place words from colon-ized file path into array
# e.g. three spaces -> three colons -> two empty words
j=1
for word in $colpath
do
    filearray[$j]="$word"
    j=$j+1
done

# reconstruct file path word by word
# after each addition, check file existence
# if non-existent, re-add lost [space] and continue until found
name=""
for seg in "${filearray[@]}"
do
    name="$name$seg"
        if [[ -f "$name" ]]
        then
            echo "$name"
            break
        fi
    name="$name "
done

All this trouble because the default IFS doesn't count "emptiness" between the spaces as words, but rather collapses them all.


Source: (StackOverflow)

Mac Automator Save to Current Directory

I am creating a basic Automator service so that I can select a group of images and resize them for our CMS. The thing that keeps messing me up is that I can't find a good way to make the resized images save to the directory where the current images are. I want to keep them grouped and not have to save them to the Desktop or some other arbitrary folder. Does anyone know of a good way to tell an automator service to save to the current directory? Thanks.


Source: (StackOverflow)

How do I run an Automator action, shell script or AppleScript on startup in OS X?

I know you can run applications on startup on a Mac, but can you run an Automator action, a Service, a shell script, or an AppleScript on startup instead?

I also know you can save all of these as an application, but I don't want it opening in the dock.


Source: (StackOverflow)

Remove All Illegal Characters from All Filenames in a Given Folder and subfolders

I Know this was was basically answered and the automator with the shell script (Sanitize Filenames) works great, but I need it to also do all subfolders as well. And if possible trim the file name down to 50 characters while retaining the file extension. I had found a line of bash code that truncated the file but it also stripped the extension and that does not work well when transferring these files from Macs to Windows.

The script as it stands is this

for f in "$1"/*; do
dir=$(dirname "$f")
file=$(basename "$f")
mv "$f" "${dir}/${file//[[:cntrl:]\\\/:*?\"<>|]/_}" 
done 

I am not opposed to using applescript in automator to complete this task.


Source: (StackOverflow)

OS X Snow Leopard: Finder automator item for creating a new text file

how can I create a Finder automaton item that appears in 'Services' for creating a new text file inside a file folder? I use TextMate, so better if the solution is editor-agnostic (rather than using TextEdit).


Source: (StackOverflow)

Apple Automator "New PDF from Images" maintaining same filename

I will potentially have 26k of old legacy PICT images to transfer first to PDF for migration. I am using Apple Automator and also the "Dispense Items Incrementally" to loop through it. However, I can't seem to let "New PDF from Images" to remember the original filename. Anyone able to offer some advice :)

FYI, I am transforming it to PDF because I can't do it using ImageMagick to convert directly to my ultimate JPEG format. Due to the fact that my PICT was created very long ago and thus has some convert: improper image header error. See this ticket for more information.

Thus I am doing a intermediate convert PICT to PDF first, then convert that PDF to JPEG :)

The only thing left is the naming of the "Output File Name" which do not allow me to identify original filename.

See the screen here:


Source: (StackOverflow)

Mac OS X: how do I change to Qwerty / Dvorak with a terminal command?

I want to use Automator to change to Qwerty before it opens StarCraft2.

Any suggestions?


Source: (StackOverflow)

How do I join various images next to each other in OS X?

I would like to join various PNG images horizontally in Mac, either using the console or Automator. Is this possible? How?

An example:

Given these two images:

enter image description here

enter image description here

The result would be:

enter image description here

The images have the same size but their size is not constrained. The number of images is between 2 and a few dozen.


Source: (StackOverflow)

Folder actions on OS X observing all subfolders

I have a folder that I would like to add a folder action to. The action works great when the file is added to the top level. But when a file is added to and sub-folders, the action is not enabled. Is there a way to ensure that a folder action is enabled when a file is added to any of its subfolders?


Source: (StackOverflow)

Keyboard shortcut for Service inĀ OS X doesn't work

I just wrote a script through Automator to make a keyboard shortcut under the title "New Finder Window Home":

on run {input, parameters}

    tell application "Finder"
        activate
        make new Finder window to home
    end tell

    return input
end run

When I run the script from Automator, the Finder opens my home tab. Then I checked "New Finder Window Home" from System Preferences > Keyboard > Keyboard Shortcuts > Services and assigned ControlOptionCommandSpace as the shortcut.

Unfortunately, the shortcut is not working! Any suggestions?


Source: (StackOverflow)

Resize images via drag and drop on OSX with good quality

I want to be able to drag and drop images on an application(icon) which preferably doesn't run. This application has to resize the images to 600x450px and drop them somewhere.

I already created an Automator action which does exactly that but the quality is less then stellar compared to having it resized via the Preview-function or Photoshop. Below you can find an example pictures resized in Automator and Photoshop.

While there are Photoshop Automator Actions http://www.robotphotoshop.com/?page_id=8 they aren't compatible with Photoshop CS6 yet.

So for now I'm looking for something else which does the job with good quality and compression.

Automator resized picture Automator resized picture

Photoshop resized picture Photoshop resized picture


Source: (StackOverflow)

How to change the appearance of empty folders in finder using Automator?

I'm trying to use Apple Automator to label empty folders in a heirarchy. Basically, I start off a project with a heirarchy of empty folders and fill them as I work. I want a workflow to label all empty folders (gray) that contain no files and their descendants also contain no files.

In other words, when I create the empty project, all folders should be gray, as there are no "files" anywhere, just empty folders. However, once I place a file somewhere, it's parent and all of it's grandparents would no longer be labeled gray.

I thought I found what I needed at How to change the appearance of empty folders in finder? however, it is labeling empty folders. In my project, only the last descendants would ever be gray because all of the parent folders contain folders, therefore, not empty.

Here's the code I'm running in a /bin/bash shell script in Automator:

find "$@" -type d -empty

And then I'm passing it to a "Label finder items" to turn the results gray.

Here's the result I'm getting when run on a test folder:

  • Test Folder (not gray)
    • Folder One (gray)
    • Folder Two (not gray)
      • Folder A (gray)
    • Folder Three (not gray)
      • Test.txt
    • Folder Four (not gray)
      • Folder A (not gray)
        • Test.txt

And here's the result I'm looking for:

  • Test Folder (not gray)
    • Folder One (gray)
    • Folder Two (gray)
      • Folder A (gray)
    • Folder Three (not gray)
      • Test.txt
    • Folder Four (not gray)
      • Folder A (not gray)
        • Test.txt

Any help will be GREATLY appreciated!

Oh, also, I beleive I can run the workflow from Hazel. If you have a better way to have it automatically run occasionally, I'd love to know that as well.

Thanks.

Edit: Just realized that the .ds_store files (I assume) are causing folders to also not appear empty, if, for instance, I delete the last file in a folder.


Source: (StackOverflow)