On 01/20/2019, at 15:34, Dante Majorana <the.d....@gmail.com <mailto:the.d....@gmail.com>> wrote: > With the standard "choose folder with prompt" as I might have folders in > various disks and the main hard drive in documents, desktop ...
Hey Dante, Well, the simplest method for non-shell-heads is probably: ---------------------------------------------------------------- # Auth: Christopher Stone # dCre: 2019/01/20 23:32 # dMod: 2019/01/20 23:37 # Appl: BBEdit, Finder # Task: Process Files in a User Chosen Folder. # Libs: None # Osax: None # Tags: @Applescript, @Script, @BBEdit, @Finder, @Process, @Files, @Folder ---------------------------------------------------------------- tell application (path to frontmost application as text) set targetFolder to choose folder end tell tell application "Finder" set fileList to files of targetFolder as alias list end tell tell application "BBEdit" repeat with theFile in fileList open theFile tell front text window delete line 3 delete line (7 - 1) delete line (9 - 2) save its document close end tell end repeat end tell ---------------------------------------------------------------- You should be able to read the script and tell what it's doing, but let me know if anything is opaque. Now then – if you're brave and want a faster solution – you can quickly change the files in-place with `sed` in a shell script. HEED the WARNINGS! listed in the script header! This shell script will be faster and more transparent than the AppleScript. #!/usr/bin/env bash # -------------------------------------------------------------------------- # Auth: Christopher Stone # dCre: 2019/01/21 00:16 # dMod: 2019/01/21 01:21 # Task: Delete Lines 3, 7, and 9 from files in the front Finder Window. # Tags: @ccstone, @Shell, @Script, @Delete, @Lines, @Front, @Finder, @Window # -------------------------------------------------------------------------- # WARNINGS! # This script operates on the FRONTMOST Finder Window. # Files are CHANGED in-place and are NOT backed up first. # Test with TEST files – NOT production files! # -------------------------------------------------------------------------- # set -x # Debugging on/off export LC_ALL="en_US.UTF-8" read -r -d '' asCmdStr <<'EOF' try tell application "Finder" return POSIX path of (target of front window as alias) end tell on error errMsg return errMsg end try EOF asResult=$(osascript -e "$asCmdStr"); if [[ "$asResult" == "Can’t "* ]]; then echo "$asResult"; # Ideally throw an error message here... else targetDir="$asResult"; cd "$targetDir"; oldIFS=$IFS; IFS=$'\n'; for filePath in $('ls' -1) do sed -i "" ' 3d 7d 9d ' "$filePath" done IFS=$oldIFS; fi While this script can run from BBEdit (or another shell-script runner) just fine, I personally would run it using a keyboard shortcut via FastScripts <https://www.red-sweater.com/fastscripts/> in the Finder. NOTE – At the moment there is NO “Are You Sure You Wan't to Do this?” dialog – it's run and done. -- Best Regards, Chris -- This is the BBEdit Talk public discussion group. If you have a feature request or need technical support, please email "supp...@barebones.com" rather than posting to the group. Follow @bbedit on Twitter: <https://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.