Sorry, Thomas. Just to catch you up...the script you posted works great. It finds all text in brackets and convert them to notes when they are preceeded by a space (because there is a space in the search string " \\[.+?\\]"). What I'd like to do is append some additional lines of code to the script you posted that also finds all bracketed text that is not preceeded by a space (because it starts the paragraph) and comprises the entire paragraph. I know that the GREP I need to use is "^\\[.+?\\]$", but I don't know enough Javascript to code it properly.
You can not convert text to notes using Find/Change settings, which is why I would like it to be a script. It doesn't matter if the brackets stay in the notes are not, as long as the information that's inside the brackets gets converted.
This will run two searches, is this what you need?
var myDocument = app.activeDocument;
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
//Set the find options.
app.findChangeGrepOptions.includeFootnotes = false;
app.findChangeGrepOptions.includeHiddenLayers = false;
app.findChangeGrepOptions.includeLockedLayersForFind = false;
app.findChangeGrepOptions.includeLockedStoriesForFind = false;
app.findChangeGrepOptions.includeMasterPages = false;
//Regular expression for finding an email address.
app.findGrepPreferences.findWhat = " \\[.+?\\]";
var myFoundItems = myDocument.findGrep();
for(i = myFoundItems.length-1; i >= 0; i--) {
try {
var myNote = myFoundItems.convertToNote();
// Delete the [ ]
myNote.characters.firstItem().remove();
myNote.characters.lastItem().remove();
} catch (e) {
alert("The string: " + myFoundItems.contents + " could not be converted to note");
}
}
app.findGrepPreferences.findWhat = "^\\[.+?\\]$";
var myFoundItemsTwo = myDocument.findGrep();
//Clear the find/change preferences after the search.
app.findGrepPreferences = NothingEnum.nothing;
app.changeGrepPreferences = NothingEnum.nothing;
for(i = myFoundItemsTwo.length-1; i >= 0; i--) {
try {
var myNote = myFoundItemsTwo.convertToNote();
// Delete the [ ]
myNote.characters.firstItem().remove();
myNote.characters.lastItem().remove();
} catch (e) {
alert("The string: " + myFoundItemsTwo.contents + " could not be converted to note");
}
}