Automator: Service to list File Paths of selected items, into Text File
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
How can this Automator Service for Finder be created?
- I'd like to be able to use Finder's Context menu (by right-clicking a Finder item) to run a Service that gets the file paths of the selected files.
- The paths should be entered into a Text File (which can be unsaved or saved in the current folder).
Furthermore:
I currently only need to be able to get the paths of multiple selected files – but not the paths of subfolder contents, etc. I hope that serves not to overcomplicate things.
I would prefer if the filenames don't have Escaping Spaces (
"Like This"
), but instead normal spaces – but if there's a setting for that, I'd like how to alter between the modes within the script.
finder automator path
add a comment |Â
up vote
2
down vote
favorite
How can this Automator Service for Finder be created?
- I'd like to be able to use Finder's Context menu (by right-clicking a Finder item) to run a Service that gets the file paths of the selected files.
- The paths should be entered into a Text File (which can be unsaved or saved in the current folder).
Furthermore:
I currently only need to be able to get the paths of multiple selected files – but not the paths of subfolder contents, etc. I hope that serves not to overcomplicate things.
I would prefer if the filenames don't have Escaping Spaces (
"Like This"
), but instead normal spaces – but if there's a setting for that, I'd like how to alter between the modes within the script.
finder automator path
4
You can get the pathnames in Finder after selecting the items, right-click and then press the option key. Copy n Items changes to: Copy n Items as Pathnames
– user3439894
Aug 27 at 18:43
@user3439894 Wow, had no idea, thanks! I guess I can't accept it as an answer, as it's the right answer to the wrong question. But this is the solution I was looking for.
– Winterflags
Aug 27 at 18:46
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
How can this Automator Service for Finder be created?
- I'd like to be able to use Finder's Context menu (by right-clicking a Finder item) to run a Service that gets the file paths of the selected files.
- The paths should be entered into a Text File (which can be unsaved or saved in the current folder).
Furthermore:
I currently only need to be able to get the paths of multiple selected files – but not the paths of subfolder contents, etc. I hope that serves not to overcomplicate things.
I would prefer if the filenames don't have Escaping Spaces (
"Like This"
), but instead normal spaces – but if there's a setting for that, I'd like how to alter between the modes within the script.
finder automator path
How can this Automator Service for Finder be created?
- I'd like to be able to use Finder's Context menu (by right-clicking a Finder item) to run a Service that gets the file paths of the selected files.
- The paths should be entered into a Text File (which can be unsaved or saved in the current folder).
Furthermore:
I currently only need to be able to get the paths of multiple selected files – but not the paths of subfolder contents, etc. I hope that serves not to overcomplicate things.
I would prefer if the filenames don't have Escaping Spaces (
"Like This"
), but instead normal spaces – but if there's a setting for that, I'd like how to alter between the modes within the script.
finder automator path
edited Aug 27 at 18:58
asked Aug 27 at 18:14


Winterflags
1,65493066
1,65493066
4
You can get the pathnames in Finder after selecting the items, right-click and then press the option key. Copy n Items changes to: Copy n Items as Pathnames
– user3439894
Aug 27 at 18:43
@user3439894 Wow, had no idea, thanks! I guess I can't accept it as an answer, as it's the right answer to the wrong question. But this is the solution I was looking for.
– Winterflags
Aug 27 at 18:46
add a comment |Â
4
You can get the pathnames in Finder after selecting the items, right-click and then press the option key. Copy n Items changes to: Copy n Items as Pathnames
– user3439894
Aug 27 at 18:43
@user3439894 Wow, had no idea, thanks! I guess I can't accept it as an answer, as it's the right answer to the wrong question. But this is the solution I was looking for.
– Winterflags
Aug 27 at 18:46
4
4
You can get the pathnames in Finder after selecting the items, right-click and then press the option key. Copy n Items changes to: Copy n Items as Pathnames
– user3439894
Aug 27 at 18:43
You can get the pathnames in Finder after selecting the items, right-click and then press the option key. Copy n Items changes to: Copy n Items as Pathnames
– user3439894
Aug 27 at 18:43
@user3439894 Wow, had no idea, thanks! I guess I can't accept it as an answer, as it's the right answer to the wrong question. But this is the solution I was looking for.
– Winterflags
Aug 27 at 18:46
@user3439894 Wow, had no idea, thanks! I guess I can't accept it as an answer, as it's the right answer to the wrong question. But this is the solution I was looking for.
– Winterflags
Aug 27 at 18:46
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
If you're looking for something that's more "pure Automator," here's one option (although, as was mentioned in the comments, right-clicking on the items in Finder, holding option, and selecting Copy Items as Pathnames
is probably the easiest solution):
- Accepts
files or folders
inFinder
- Set Value of Variable
Inputs
- Run Shell Script:
/usr/bin/dirname "$1"
(make sure to pass inputas arguments
) - Set Value of Variable
Parent Folder
- Get Value of Variable
Inputs
<-- this should not accept input (right-click on the action and selectIgnore Input
) - New Text File (
Plain text
, [whatever file name you want],Parent Folder
(drag this in from the variables list))
I've included a screenshot below:
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
add a comment |Â
up vote
1
down vote
No script is needed, as this is already built into Finder (this works for one or multiple files):
Right click on the file(s) in Finder
Press and hold option
Select
Copy [file name] as Pathname
(orCopy [#] Items as Pathnames
for multiple files) in the context menuThe pathnames are now saved to your clipboard. You can paste them into Notes or a text file
2
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
add a comment |Â
up vote
1
down vote
Assuming you know how to create save and use a service menu item...
Script
on run input, parameters
set myExport to ""
repeat with x in input
set myExport to myExport & the POSIX path of x & return
end repeat
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
end run
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
1
Change the second-to-last line totell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line todo shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.
– aaplmath
Aug 27 at 19:02
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
 |Â
show 2 more comments
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
If you're looking for something that's more "pure Automator," here's one option (although, as was mentioned in the comments, right-clicking on the items in Finder, holding option, and selecting Copy Items as Pathnames
is probably the easiest solution):
- Accepts
files or folders
inFinder
- Set Value of Variable
Inputs
- Run Shell Script:
/usr/bin/dirname "$1"
(make sure to pass inputas arguments
) - Set Value of Variable
Parent Folder
- Get Value of Variable
Inputs
<-- this should not accept input (right-click on the action and selectIgnore Input
) - New Text File (
Plain text
, [whatever file name you want],Parent Folder
(drag this in from the variables list))
I've included a screenshot below:
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
add a comment |Â
up vote
2
down vote
accepted
If you're looking for something that's more "pure Automator," here's one option (although, as was mentioned in the comments, right-clicking on the items in Finder, holding option, and selecting Copy Items as Pathnames
is probably the easiest solution):
- Accepts
files or folders
inFinder
- Set Value of Variable
Inputs
- Run Shell Script:
/usr/bin/dirname "$1"
(make sure to pass inputas arguments
) - Set Value of Variable
Parent Folder
- Get Value of Variable
Inputs
<-- this should not accept input (right-click on the action and selectIgnore Input
) - New Text File (
Plain text
, [whatever file name you want],Parent Folder
(drag this in from the variables list))
I've included a screenshot below:
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
If you're looking for something that's more "pure Automator," here's one option (although, as was mentioned in the comments, right-clicking on the items in Finder, holding option, and selecting Copy Items as Pathnames
is probably the easiest solution):
- Accepts
files or folders
inFinder
- Set Value of Variable
Inputs
- Run Shell Script:
/usr/bin/dirname "$1"
(make sure to pass inputas arguments
) - Set Value of Variable
Parent Folder
- Get Value of Variable
Inputs
<-- this should not accept input (right-click on the action and selectIgnore Input
) - New Text File (
Plain text
, [whatever file name you want],Parent Folder
(drag this in from the variables list))
I've included a screenshot below:
If you're looking for something that's more "pure Automator," here's one option (although, as was mentioned in the comments, right-clicking on the items in Finder, holding option, and selecting Copy Items as Pathnames
is probably the easiest solution):
- Accepts
files or folders
inFinder
- Set Value of Variable
Inputs
- Run Shell Script:
/usr/bin/dirname "$1"
(make sure to pass inputas arguments
) - Set Value of Variable
Parent Folder
- Get Value of Variable
Inputs
<-- this should not accept input (right-click on the action and selectIgnore Input
) - New Text File (
Plain text
, [whatever file name you want],Parent Folder
(drag this in from the variables list))
I've included a screenshot below:
answered Aug 27 at 18:51


aaplmath
1,5421029
1,5421029
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
add a comment |Â
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
+1 Like use of pure Automator. I myself am not too good at pure Automator
– JBis
Aug 27 at 20:22
add a comment |Â
up vote
1
down vote
No script is needed, as this is already built into Finder (this works for one or multiple files):
Right click on the file(s) in Finder
Press and hold option
Select
Copy [file name] as Pathname
(orCopy [#] Items as Pathnames
for multiple files) in the context menuThe pathnames are now saved to your clipboard. You can paste them into Notes or a text file
2
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
add a comment |Â
up vote
1
down vote
No script is needed, as this is already built into Finder (this works for one or multiple files):
Right click on the file(s) in Finder
Press and hold option
Select
Copy [file name] as Pathname
(orCopy [#] Items as Pathnames
for multiple files) in the context menuThe pathnames are now saved to your clipboard. You can paste them into Notes or a text file
2
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
add a comment |Â
up vote
1
down vote
up vote
1
down vote
No script is needed, as this is already built into Finder (this works for one or multiple files):
Right click on the file(s) in Finder
Press and hold option
Select
Copy [file name] as Pathname
(orCopy [#] Items as Pathnames
for multiple files) in the context menuThe pathnames are now saved to your clipboard. You can paste them into Notes or a text file
No script is needed, as this is already built into Finder (this works for one or multiple files):
Right click on the file(s) in Finder
Press and hold option
Select
Copy [file name] as Pathname
(orCopy [#] Items as Pathnames
for multiple files) in the context menuThe pathnames are now saved to your clipboard. You can paste them into Notes or a text file
edited Aug 27 at 19:17


aaplmath
1,5421029
1,5421029
answered Aug 27 at 18:53


Buscar웃
31.3k539105
31.3k539105
2
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
add a comment |Â
2
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
2
2
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
Plus one- trivial hand work that does not need scripting
– fd0
Aug 27 at 19:06
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
-1 The OP is new to Automator. Providing a scripting alternative would allow them to learn. This solution while correct, does not answer the OPs question entirely.
– JBis
Aug 27 at 20:21
add a comment |Â
up vote
1
down vote
Assuming you know how to create save and use a service menu item...
Script
on run input, parameters
set myExport to ""
repeat with x in input
set myExport to myExport & the POSIX path of x & return
end repeat
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
end run
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
1
Change the second-to-last line totell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line todo shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.
– aaplmath
Aug 27 at 19:02
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
 |Â
show 2 more comments
up vote
1
down vote
Assuming you know how to create save and use a service menu item...
Script
on run input, parameters
set myExport to ""
repeat with x in input
set myExport to myExport & the POSIX path of x & return
end repeat
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
end run
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
1
Change the second-to-last line totell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line todo shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.
– aaplmath
Aug 27 at 19:02
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
 |Â
show 2 more comments
up vote
1
down vote
up vote
1
down vote
Assuming you know how to create save and use a service menu item...
Script
on run input, parameters
set myExport to ""
repeat with x in input
set myExport to myExport & the POSIX path of x & return
end repeat
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
end run
Assuming you know how to create save and use a service menu item...
Script
on run input, parameters
set myExport to ""
repeat with x in input
set myExport to myExport & the POSIX path of x & return
end repeat
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
end run
edited Aug 27 at 21:21
answered Aug 27 at 18:50


JBis
4,3121838
4,3121838
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
1
Change the second-to-last line totell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line todo shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.
– aaplmath
Aug 27 at 19:02
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
 |Â
show 2 more comments
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
1
Change the second-to-last line totell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line todo shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.
– aaplmath
Aug 27 at 19:02
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Finder sends the files to input
– JBis
Aug 27 at 18:54
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
@user3439894 Oh I see now. Yes that's correct.
– JBis
Aug 27 at 18:56
1
1
Change the second-to-last line to
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line to do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.– aaplmath
Aug 27 at 19:02
Change the second-to-last line to
tell application "Finder" to set myPath to (POSIX path of (get (container of (first item of input)) as text))
and the last line to do shell script "echo " & the quoted form of myExport & " > " & the quoted form of (myPath & "/file_list.txt")
and it'll work if the first item isn't a directory. N.B.: There's probably a cleaner way to accomplish this.– aaplmath
Aug 27 at 19:02
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@aaplmath done thanks!
– JBis
Aug 27 at 19:38
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
@user3439894 can't fix now on mobile will fix later
– JBis
Aug 27 at 20:19
 |Â
show 2 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fapple.stackexchange.com%2fquestions%2f334878%2fautomator-service-to-list-file-paths-of-selected-items-into-text-file%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
4
You can get the pathnames in Finder after selecting the items, right-click and then press the option key. Copy n Items changes to: Copy n Items as Pathnames
– user3439894
Aug 27 at 18:43
@user3439894 Wow, had no idea, thanks! I guess I can't accept it as an answer, as it's the right answer to the wrong question. But this is the solution I was looking for.
– Winterflags
Aug 27 at 18:46