Skip to main content
Known Participant
February 24, 2015
Question

Move text frame to a layer

  • February 24, 2015
  • 2 replies
  • 1922 views

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

   return

end if

end

--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

       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

               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

This topic has been closed for replies.

2 replies

Inspiring
October 12, 2017

Eg.

From Paragraph Styles AUTHOR and TEACHER to Layers AUTHOR and TEACHER.

Inspiring
October 12, 2017

Hi.

It works in Indesign CS6?

Regards,

Inspiring
October 12, 2017

Hi,

     Textbox may contains many paragraphs (paragraph styles) know.  can you explain clearly with screenshots?

Inspiring
October 12, 2017

Hi.

That's it.