Automator to execute shell script with an input text file, copy it to specific directory I'm simplifying making a .deb file with Automator. I currently have a shell script that does some simple actions -


Ask the user for text input
Do some directory parsing
Execute a command with the text input as a variable
run the dpkg-deb program and output to the desktop


That's all well and good, but .deb files must have a "control" text file with some fields filled out, and the file has to be in a specific path, with the control file residing in a DEBIAN subdirectory like so

AppName/DEBIAN/control


What I would like to do, is create the control file, and drop it on the Automator workflow and have it run the script with the control file as an input parameter. I would need the script to "copy this file to AppName/DEBIAN/ and create the DEBIAN folder if it doesn't exist.

Where AppName == A specific line from the control file

Can anyone help?
EDIT: Workflow now works with one bug: running the workflow twice results in two copies of the control file being copied

Make a new Automator SERVICE. At the beginning, for "receives selected as input" choose "documents". Add the process "set value of variable" and make a new "destination path" variable (default variable name is "destination path"). Add the process "open finder items" to the beginning to open the control file. Add the process "run applescript" to the workflow the code is the following:

on run {input, parameters}

set LineNumber to (the line in which the path is specified in the control file)
tell application "TextEdit"
    set theVariable to paragraph LineNumber of document 1
    set thePath to POSIX path of theVariable
    set thePath to text 1 thru -2 of thePath
end tell

return thePath
end run


I don't know why this couldn't have been in the same block, but you need to add a separate AppleScript process. The code is as follows:

on run {input, parameters}

tell application "Finder"
    set theFolder to POSIX path of input &amp; "/DEBIAN"
    try
        make new folder in folder input with properties {name:"DEBIAN"}
    end try
end tell

return theFolder
end run


Add the process "set value of variable" and make a new destination path variable (default name is "destination path 1").
Add the "get value of variable" process and get the value of the variable with the path of the input file ("destination path"). Click on "options" on this process and check "ignore this action's input".
After this, Automator has a process called "copy finder items" and this can be used to copy the input (the output of "get value of variable", which is the input file). This worked for me, hope it works for you as well. Good luck :)