Combine txt files
I have more than 100 text files and would like to combine them into on single text file or other kind,
ex HTML or pdf
Is it possible ?
MacBook Air 15″
I have more than 100 text files and would like to combine them into on single text file or other kind,
ex HTML or pdf
Is it possible ?
MacBook Air 15″
Put all of the text files in a folder on your Desktop. Ensure that each has a .txt extension. Then, launch the Terminal application, and enter the following where the folder theTextFiles is a placeholder for your name choice. The >> is UNIX for concatenate.
cd ~/Desktop/theTextFiles
/usr/bin/pr *.txt >> ../combined_text.txt
That pr command by default, will produce individual page headers bearing the name of the text file and its page number in this format:
Sep 20 18:09 2023 apple.txt Page 1
Automator has a combine text action. Use this sequence of Automator commands:
Ask for Finder Items
Get Selected Finder Items
Combine Text Files
New Text File
Choose Utilities from the Finder's Go menu, open the Script Editor, and run:
set the_text to ""
tell application "Finder"
repeat with thisFile in (selection as alias list)
set the_text to the_text & (read thisFile) & return
end repeat
end tell
return the_text
(244738)
Put the line next to '& return' in the script:
set the_text to ""
tell application "Finder"
repeat with thisFile in (selection as alias list)
set the_text to the_text & (read thisFile) & return & "-----------------------------------" & return
end repeat
end tell
return the_text
If desired, this can be:
set the_text to the_text & (read thisFile) & return & name of thisFile & ":" & return
(244775)
It worked! (Martin R solution)
I would like Automator to enter the title for each text file that is collected and not just the text
Or at least draw a line between the different text files
I also got some error messages
Combine txt files