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

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



How can this Automator Service for Finder be created?



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.


"Like This"





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





3 Answers
3



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


Copy Items as Pathnames


files or folders


Finder


Inputs


/usr/bin/dirname "$1"


as arguments


Parent Folder


Inputs


Ignore Input


Plain text


Parent Folder



I've included a screenshot below:



Screenshot of Service





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



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


Copy [file name] as Pathname


Copy [#] Items as Pathnames



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





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



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



![enter image description here


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





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



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





@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






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

ャフサォクコ ケウ,コ,ワ メ,ロスョノ゙,クネ,フムカヤヲニ,エコ゚ツ ウイオン゙ケワサネォキモュキォウイノンコチ゚メヌナイゥフュ,カヒウネェ ネ,ホノケ,ムュキ ッボーミュハ,チ ツス ィ メウイマヤ,゙ウチ ヅ ロ,ォジヌェ ャヌット ェ,マャ,チナエヒネソキツテ トホヲヲミーァ

How do I collapse sections of code in Visual Studio Code for Windows?