-- Set the path to the folder containing your text files
set folderPath to "YourFolderPath"
-- Create or open "All Extracts.txt" for writing
set outputFile to (open for access (folderPath & "All Extracts.txt") with write permission)
-- List of file paths in the manifest
set manifest to {"/path/to/your/file1.txt", "/path/to/your/file2.txt"} -- Add your file paths here
-- Process each file in the manifest
repeat with filePath in manifest
-- Open the current file
set inputFile to open for access filePath
-- Read the content of the file
set fileContent to read inputFile as «class utf8»
-- Close the current file
close access inputFile
-- Extract text blocks based on ";;" delimiter
set textBlocks to paragraphs of fileContent
set extractedText to ""
set isBlockActive to false
repeat with lineText in textBlocks
if lineText starts with ";;" then
if isBlockActive then
-- Append the extracted text to "All Extracts.txt"
write extractedText & lineText & linefeed to outputFile starting at eof
set extractedText to "" -- Reset for the next block
else
set isBlockActive to true
end if
else
if isBlockActive then
set extractedText to extractedText & lineText & linefeed
end if
end if
end repeat
end repeat
-- Close "All Extracts.txt" after processing all files
close access outputFile
This script assumes that each text block is started with ";;" and ends before the next ";;" delimiter. It extracts the text blocks and appends them to the "All Extracts.txt" file in the same folder as your text files.
Remember to replace "/path/to/your/file1.txt", "/path/to/your/file2.txt" with the actual file paths in your manifest. Also, make sure to back up your data before running any script, especially if it modifies files.
-------
I don't use AppleScript so I don't know if this will work, but my experience with chatGPT so far has been that at least for the sort of simple Python and JavaScript programming I do as a clunky hobbyist, it's usually pretty durn good!
Also, I apologize if I've misunderstood your scenario.
Good luck!
- help on notes project - 1 Update
Andrew McDowell <andy...@gmail.com>: Dec 16 08:47AM -0800
- notes project description
- I have a number of notes journals, some up to 100k words, written over
some 30 years. Multiple topics in each file. My project is to extract and
compile all meaningful notes from these journals and split them out by
topic into separate files. Everything will be plain text, at least
initially (I'll have to sanitize some Word files). My thought is to use
BBEdit and Apple Scripts to accomplish this, as it's the only thing I've
found that shows any promise at all. If anyone has a better idea I'm
listening.
- I would prep the notes journal files into delimited text blocks as seen
below. Following that is my pseudo code attempt at a script. I'm a beginner
with Apple Scripts and with BBEdit. I am not a coder but willing to learn
enough scripting, regex, etc to do this. Help is appreciated. Let me know
if I can be clearer.
- If this works I'm sure I'll find other things to automate for this or
other projects.
-----
- proposed form for 'prepped source file' (notes journal)
- misc (unwanted) text
- filename1 (target file for the following clip)
- ;; (beginning delimiter)
- heading, date
- text body
- ;; (end delimiter)
- misc (unwanted) text
- filename2
- ;;
- heading, date
- text body
- ;;
- misc text
- etc ... to end of file
-----
- proposed (pseudo code) script
- find 1st filename
- index that file to front
- select & copy delimited text (;; text ;;)
- append selection to target file
- find next filename in source file & repeat
- no more filenames?
- done.
-----
- maybe only an end delimiter is needed, if filename may serve as beginning
delimiter?
- If anyone offers a script, please translate it for me (I'm a dummy)
- Or if there's a better way...
Thanks, Andy
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to bbedit+un...@googlegroups.com.