title: Google apps script: Google Slides - Is it possible to pull in slide text or slide number when using "SlidesApp.create("?
body: <p>I am trying to use find out if there is a way to add a unique identifier so that when a script with &quot;SlidesApp.create&quot; is used it generates a different presentation name each time. For context I have a deck with arounds 40 slides. I'm using the below script graciously provided by user Tanaike to export slides that I have selected into a new deck presentation. In my screenshot example below I selected slides 2 and 3 and used the script to export only those slides into a new deck presentation. Currently the script uses <code>SlidesApp.create(&quot;newSlides&quot;); </code> to name the newly created slide presentation &quot;newSlides&quot; . My goal is to be able to appended the title so that the newly created presentation with the exported slides can pull in either the first selected slide's actual text or just the slide number from the original deck.</p>
  <p>Using my screenshot example below it would be either</p>
  <ul>
  <li>&quot;newSlides 2&quot; - since the first slide of the multiple selected slides in the original deck presentation is the slide 2
  or</li>
  <li>&quot;newSlides CAT&quot;</li>
  </ul>
  <p><a href="https://i.stack.imgur.com/gH4Tg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gH4Tg.png" alt="Screenshot" /></a></p>
  <p>for context below is the full script I am using</p>
  <pre><code>function myFunction() {
    // 1. Retrieve the selected slides.
    const s = SlidesApp.getActivePresentation();
    const pageRange = s.getSelection().getPageRange();
    if (!pageRange) return;
    const slides = pageRange.getPages();
  
    // 2. Create a new Google Slides.
    const newSlides = SlidesApp.create(&quot;newSlides&quot;);
  
    // 3. Copy the selected slides to the new Google Slides.
    slides.reverse().forEach(s =&gt; newSlides.insertSlide(0, s.asSlide(), SlidesApp.SlideLinkingMode.LINKED));
  
    // 4. Delete the initial slide in the new Google Slides.
    newSlides.getSlides()[slides.length].remove();
  }
  </code></pre>