On 05/06/2021, at 10:06, Howard <[email protected] 
<mailto:[email protected]>> wrote:
> Patrick, your way of concatenating individual files works well.
> 
> I have a folder that contains both folders whose contents I would like to 
> include in the concatenation as well as separate individual files. Is there a 
> way to do that in BBEdit?


Hey Howard,

If you're going to do this regularly you might want to systematize the process.

Place the following script in:

~/Library/Application Support/BBEdit/Scripts/


#!/usr/bin/env bash
# -------------------------------------------------------------------------
# Auth: Christopher Stone
# dCre: 2021/05/07 06:07
# dMod: 2021/05/07 06:07 
# Task: Recursively Concatenate Files in the Front Finder Window.
# Tags: @ccstone, @Shell, @Script, @Concatenate, @Files, @Finder, @BBEdit
# -------------------------------------------------------------------------

# Acquire the path to the Front Finder Window. (Finder Insertion Location.)
read -r -d '' asCmdStr <<'EOF'
   tell application "Finder"
      set targetFolder to insertion location as alias
      return POSIX path of targetFolder
   end tell
EOF
targetFolderPath=$(osascript -e "$asCmdStr")

# Change the working directory to the Finder Insertion Location.
cd "$targetFolderPath"

# Find files, concatenate their contents, send result to BBEdit.
find -E . -type f \( ! -name ".*" \) -exec sed -n '1,$p' {} \; | bbedit


Give it a memorable name.

If desired give it a keyboard shortcut in BBEdit's Menus & Shortcuts 
Preferences.


REQUIREMENTS:

BBEdit's command line tools must be installed.



USAGE:

1) Open the desired target directory in the Finder, so its window is FRONTMOST.

2) Run the script from BBEdit's Script menu or via a keyboard shortcut.


RESULT:

A new window will be opened in BBEdit containing the concatenated contents of 
every file in the target directory (recursive).


--
Best Regards,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/6C639B20-5E85-4D55-AF42-0A2B82EB1B21%40gmail.com.

Reply via email to