concatenate files in BBEdit
concatenate files in BBEdit
- Subject: concatenate files in BBEdit
- From: Ludo Smissaert <email@hidden>
- Date: Sun, 16 Feb 2003 12:43:20 +0100
Hello
Apologies for cross posting, I have send this to BBEdit scripting list, but there seems to be no traffic at all, and I really need an answers for this.
There is an applescript at the end of this message that I cooked up, for BBEdit 6.5 on OS 9.2.
What it does:
Working on two (BBEdit-)text files in BBEdit, two associated text windows are open. The script concatenates the two files, set some tags around it, and saves the result to a folder. The text windows of the files I work on, are left open untouched/unmodified, and I don't need to see the text window of the resulting file come flashing by.
But, there is one problem, the code
tell application "Finder"
set creator type of (file this_file) to "R*ch"
end tell
only works if I execute the script from within the scripteditor (Smile, in this case), and not if I save the script in BBEdits script folder, and execute it from within BBEdit. A message complains that the Finder got an error: can't set creator type to "R*ch"
I would love to hear what I am doing wrong? And if the script can be improved in some way, I would love to hear it.
Waiting patiently for your answers,
with kind regards,
Ludo Smissaert
(* the script *)
(* define the tags *)
set cs_1 to ("<CsoundSynthesizer>" & return ,
& "<CsInstruments>" & return & return)
set cs_2 to (return & return & "</CsInstruments>" & return ,
& "<CsScore>" & return & return)
set cs_3 to (return & return & "</CsScore>" & return ,
& "</CsoundSynthesizer>" & return & ";.csd Okay, by applescript :-)")
set this_file to "Data HD:the_target.txt"
tell application "BBEdit 6.5"
set this_story to (cs_1 & (text 1 of text window 1) ,
& cs_2 & (text 1 of text window 2) & cs_3)
my write_to_file(this_story, this_file)
display dialog this_file as string
end tell
-- this doesn't work, I don't know why?
tell application "Finder"
set creator type of (file this_file) to "R*ch"
end tell
(* this subroutine, I got it from apple.com *)
on write_to_file(this_data, target_file)
try
set the target_file to the target_file as text
set the open_target_file to ,
open for access file target_file with write permission
set eof of the target_file to 0
write this_data to the open_target_file starting at eof
close access the open_target_file
end try
end write_to_file
(* end the script *)
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.