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 & "/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 :)
This can be done using AppleScript, like in the question you linked to. Watch out, this is not the same as Automator.
Example script:
osascript -e 'tell application (path to frontmost application as text)
set myFile to choose file
POSIX path of myFile
end'
This uses the simplest form of the choose file
command, and puts the result in the variable myFile
. The result will be of type alias, which has a POSIX path
property, which we read in the next line. The result will be written to stdout.
Look here for all the possible optional options to the choose file
command. You can e.g. provide a custom prompt text, choose a default location, or only allow certain file types.
Best Answer
Open up
Terminal
.Your Desktop is at
~/Desktop
(the~
is a shortcut for your home folder) socd ~/Desktop
return to go there thenless test.txt
returnBy the way, if you are going to use
TextWrangler
andTerminal
you might want to visit http://www.barebones.com/support/textwrangler/ and download the TextWrangler command line tools which allow you to open a file in TextWrangler from the command line, among other things.