0 Replies Latest reply on Feb 24, 2015 10:30 AM by nellbern

    Move text frame to a layer


      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" to set 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 giving up after 6


      end if



      --loop the selected folder

      repeat with oneFile in theFiles


         tell application "Adobe InDesign CS4"

             --ignore dialogs

             set user interaction level of script preferences to never interact



             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"


                     set myLayer to layer LayerName

                     set the properties of myLayer to {locked:false}

                 on error

                     --create layer if does not exist

                     set myLayer to make layer with properties {name:LayerName, layer color:red, visible:true}

                 end try


                 --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..." giving up after 2


                 --put the prefs the way it was

                 tell application "Adobe InDesign CS4"

                     set user interaction level of script preferences to interact with all

                 end tell



             end tell --myDoc

         end tell --Indesign

      end repeat