OK, I seem to have sorted out the filePath part, but apparently AppleScript does not take many extensions with "or"? Or am I doing something wrong?
Script: *tell* *application* "BBEdit" *set* w *to* *text window* 1 *set* the_file *to* *file* *of* active document *of* w *as* *text* -- set filePath to (do shell script "/usr/bin/find ~/Dropbox/adi_dropbox/ -name" & the_file) *set* filePath *to* POSIX path *of* the_file *end* *tell* *set* parentDirectory *to* *POSIX file* (*do shell script* "dirname " & quoted form *of* POSIX path *of* the_file) *as* *alias* *tell* *application* "Finder" *delete* (*every* *item* *of* *folder* parentDirectory *whose* name *does not* *end* *with* (".tex" *or* ".pdf" *or* ".eps" *or* ".bbprojectd" *or* "tags" *or* ".ist")) *display dialog* "Folder cleaned." buttons {"OK"} *beep* *end* *tell* On Sunday, February 26, 2017 at 3:22:47 PM UTC+2, Adrian Manea wrote: > > OK, I'm pretty sure this is an easy one, but since I have close to zero > experience with AppleScript, I have to ask: > > Could anyone please help me with a script that gets the path to the > containing folder of the current (open, frontmost) text file of BBEdit? > > Concrete use: I would then add to the script the command to delete from > that folder files by extension. When running pdflatex, I get lots of > auxiliary files that are not needed, so I intend to use such a script for > "cleaning up" the folder, to be left only with .tex and .pdf files in that > folder. > > I would add to the script something like: > > > *tell* *application* "Finder" > > *delete* (*every* *item* *of* *folder* (*path to* filePath) *whose* name > *does > not* *end* *with* ".tex" *or* ".pdf" *or* ".eps" *or* ".bbprojectd" *or* > "tags" *or* ".ist") > > *end* *tell* > > But the hardest part is getting that filePath... > > Thank you! > -- This is the BBEdit Talk public discussion group. If you have a feature request or would like to report a problem, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <http://www.twitter.com/bbedit> --- You received this message because you are subscribed to the Google Groups "BBEdit Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to bbedit+unsubscr...@googlegroups.com. To post to this group, send email to bbedit@googlegroups.com. Visit this group at https://groups.google.com/group/bbedit.