Need batch ID docs. & get all instances where the paragraph style "Codes" was applied, create a new layer "PR" & move text frames containing that paragraph style to a layer "PR". This what I have so far. Any help is appreciated. ================
set source_folder to choose folder with prompt "Select folder containing Indesign Documents to move codes to a diffrent layer"
tell application "Finder"toset theFiles to files of source_folder whose name extension is"indd"
if (count of theFiles) is 0 then
display dialog "No InDesign files to process" buttons "Cancel" default button "Cancel"with icon 0 givingupafter 6
return
endif
end
--loop the selected folder
repeatwith oneFile in theFiles
tell application "Adobe InDesign CS4"
--ignore dialogs
set user interaction level ofscript preferences to never interact
activate
set myDocument to open (oneFile as alias)
tell myDocument
--find pstyle
set myPstyle to paragraph style "CODES"
-- if the page is a spread
set x to properties of spread 1
set LayerName to"PR"
try
set myLayer to layer LayerName
setthe properties of myLayer to {locked:false}
onerror
--create layer if does not exist
set myLayer to make layer with properties {name:LayerName, layer color:red, visible:true}
endtry
--get all instances where paragraph style CODES was applied only & move text frames to a PR layer
set myObjects to (every text frame whose applied paragraph style is myPstyle and item layer is myLayer)
move (every text frame whose applied paragraph style is myPstyle) to layer "PR"
close myDocument saving yes
display alert "Opening next document..."givingupafter 2
--put the prefs the way it was
tell application "Adobe InDesign CS4"
set user interaction level ofscript preferences to interact with all
endtell
--==============
endtell--myDoc
endtell--Indesign
endrepeat