BBedit: iterate through project files

Hi,

I’m looking for a way to perform an operation on every file in a BBedit project. I have everything already scripted and working smoothly for individual files but I need to perform the same operation on every file (55 of them) in a project. Right now I do it manually, select the file and run the script, 55 times. That’s not efficient.

Can someone point me in the right direction?

Thanks,
Randy

What is the operation?
In pseudocode, most apps generally follow this syntax:

tell application "application" 
 <do command> in/to the object (in this case, the HFS path of the folder)
end

Unfortunately, all the files are in different folders scattered all over the place. That’s why I put them in a project. I just want to iterate through the project files whether they are open or not, not necessarily a folder.

Here’s an example of the script.


tell application "BBEdit"
	activate
	tell text of text document 1
		replace "zzzzzzz" using selection as text options {search mode:literal, starting at top:true, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}
	end tell
	save document 1
end tell

Thanks!

This should work, but I advise you try it first with a few dummy files.

tell application "BBedit" to replace "zzzzzzz" using "whatever" searching in (get (project windows's item 1)'s text documents) options {search mode:literal, starting at top:true, showing results:0} saving yes

Hey Randy,


tell application "BBEdit"

	tell front project document
		set projectItemList to project items
	end tell

	tell front project window
		set docList to documents whose name does not end with ".bbprojectd"
	end tell

end tell

Note there’s a difference between project items and open documents.


Chris


{ MacBookPro6,1 · 2.66 GHz Intel Core i7 · 8GB RAM · OSX 10.11.1 }
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯