terminal – Expose several chosen files in Finder from script

Rather of utilizing ls, I would utilize discover so I might recover the complete courses to the files. Then I would compose the outcomes to a file (in my following option, I send out the outcomes to ~/ Desktop/foo. txt)

In Terminal, this following code modifications your existing directory site to / private/tmp/foo then discovers all files because directory site and composes the complete POSIX course of each file to the ~/ Desktop/foo. txt file.

cd/ private/tmp/foo; discover "$ PWD" -type f -mindepth 1 > > ~/ Desktop/foo. txt

Then paste this next whole block of code into Terminal This will choose and expose those files in Finder

 osascript -e '
set fooFiles to paragraphs 1 thru -2 of ¬
( check out alias (( course to desktop as text) & &" foo.txt" )). set fooAliasList to {

} repeat with i in fooFiles. set end of fooAliasList to i as POSIX file as alias.

end repeat. inform application "Finder" to expose fooAliasList'&2 >> & 1 >/ dev/null.

You can likewise include this command ; rm ~/ Desktop/foo. txt straight after the 2>&> & 1 >/ dev/null which will erase the ~/ Desktop/foo. txt file after the files get exposed.

 osascript -e '.
set fooFiles to paragraphs 1 thru -2 of ¬.
( check out alias (( course to desktop as text) & &" foo.txt" )). set fooAliasList to {}

repeat with i in fooFiles.
set end of fooAliasList to i as POSIX file as alias.
end repeat.

inform application "Finder" to expose fooAliasList.
inform application "System Occasions" to set frontmost of procedure "Finder" to real' 2>&> & 1 >/ dev/null; rm ~/ Desktop/foo. txt.

Like this post? Please share to your friends:
Leave a Reply

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: