Automator: Service to list File Paths of selected items, into Text File

The name of the pictureThe name of the pictureThe name of the pictureClash 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.







share|improve this question


















  • 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















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.







share|improve this question


















  • 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













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.







share|improve this question














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.









share|improve this question













share|improve this question




share|improve this question








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













  • 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











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 in Finder

  • Set Value of Variable Inputs

  • Run Shell Script: /usr/bin/dirname "$1" (make sure to pass input as arguments)

  • Set Value of Variable Parent Folder

  • Get Value of Variable Inputs <-- this should not accept input (right-click on the action and select Ignore 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:



Screenshot of Service






share|improve this answer




















  • +1 Like use of pure Automator. I myself am not too good at pure Automator
    – JBis
    Aug 27 at 20:22

















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 (or Copy [#] Items as Pathnames for multiple files) in the context menu


  • The pathnames are now saved to your clipboard. You can paste them into Notes or a text file






share|improve this answer


















  • 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

















up vote
1
down vote













Assuming you know how to create save and use a service menu item...



![enter image description here



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





share|improve this answer






















  • @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 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










  • @user3439894 can't fix now on mobile will fix later
    – JBis
    Aug 27 at 20:19










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "118"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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 in Finder

  • Set Value of Variable Inputs

  • Run Shell Script: /usr/bin/dirname "$1" (make sure to pass input as arguments)

  • Set Value of Variable Parent Folder

  • Get Value of Variable Inputs <-- this should not accept input (right-click on the action and select Ignore 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:



Screenshot of Service






share|improve this answer




















  • +1 Like use of pure Automator. I myself am not too good at pure Automator
    – JBis
    Aug 27 at 20:22














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 in Finder

  • Set Value of Variable Inputs

  • Run Shell Script: /usr/bin/dirname "$1" (make sure to pass input as arguments)

  • Set Value of Variable Parent Folder

  • Get Value of Variable Inputs <-- this should not accept input (right-click on the action and select Ignore 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:



Screenshot of Service






share|improve this answer




















  • +1 Like use of pure Automator. I myself am not too good at pure Automator
    – JBis
    Aug 27 at 20:22












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 in Finder

  • Set Value of Variable Inputs

  • Run Shell Script: /usr/bin/dirname "$1" (make sure to pass input as arguments)

  • Set Value of Variable Parent Folder

  • Get Value of Variable Inputs <-- this should not accept input (right-click on the action and select Ignore 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:



Screenshot of Service






share|improve this answer












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 in Finder

  • Set Value of Variable Inputs

  • Run Shell Script: /usr/bin/dirname "$1" (make sure to pass input as arguments)

  • Set Value of Variable Parent Folder

  • Get Value of Variable Inputs <-- this should not accept input (right-click on the action and select Ignore 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:



Screenshot of Service







share|improve this answer












share|improve this answer



share|improve this answer










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
















  • +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












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 (or Copy [#] Items as Pathnames for multiple files) in the context menu


  • The pathnames are now saved to your clipboard. You can paste them into Notes or a text file






share|improve this answer


















  • 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














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 (or Copy [#] Items as Pathnames for multiple files) in the context menu


  • The pathnames are now saved to your clipboard. You can paste them into Notes or a text file






share|improve this answer


















  • 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












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 (or Copy [#] Items as Pathnames for multiple files) in the context menu


  • The pathnames are now saved to your clipboard. You can paste them into Notes or a text file






share|improve this answer














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 (or Copy [#] Items as Pathnames for multiple files) in the context menu


  • The pathnames are now saved to your clipboard. You can paste them into Notes or a text file







share|improve this answer














share|improve this answer



share|improve this answer








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












  • 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










up vote
1
down vote













Assuming you know how to create save and use a service menu item...



![enter image description here



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





share|improve this answer






















  • @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 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










  • @user3439894 can't fix now on mobile will fix later
    – JBis
    Aug 27 at 20:19














up vote
1
down vote













Assuming you know how to create save and use a service menu item...



![enter image description here



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





share|improve this answer






















  • @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 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










  • @user3439894 can't fix now on mobile will fix later
    – JBis
    Aug 27 at 20:19












up vote
1
down vote










up vote
1
down vote









Assuming you know how to create save and use a service menu item...



![enter image description here



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





share|improve this answer














Assuming you know how to create save and use a service menu item...



![enter image description here



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






share|improve this answer














share|improve this answer



share|improve this answer








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 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










  • @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 Oh I see now. Yes that's correct.
    – JBis
    Aug 27 at 18:56






  • 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











  • @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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Comments

Popular posts from this blog

What does second last employer means? [closed]

List of Gilmore Girls characters

One-line joke