How to create a app with automator to run a bash script?


i want create app kind of ds store remover remove directories instead of 1 file. wondering how go doing have bash script code below need know do. have app ask root password , allow user select directory want these directories.



sudo rm -rf “.thrashes”





sudo rm -rf “.spotlight-v100”





sudo rm -rf “.trash”





sudo rm -rf “.ds_store”
 

it sounds want run bash script application. i'd rewriting in applescript:

code:
set targetdir (choose folder prompt "choose folder want clean") set targetpath posix path of targetdir set shellscript "cd " & targetpath & " rm -rf .trashes rm -rf .spotlight-v100 rm -rf .trash rm -rf .ds_store" shell script shellscript administrator privileges
you can file -> save... , choose application file format.

note doing way lets operating system deal granting root permissions - doesn't mess around handling passwords itself.

be careful. if cd command fails reason rm commands carry on regardless, in /. idea bash script exit if cd fails.
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

Comments

Popular posts from this blog

Sean Penn, "Chapo Guzman", and Rolling Stone

Subler - What is "Fix Audio Fallbacks"?

Help please Strange logs