0

How do I get the total slide count across multiple PowerPoint presentations? I have a folder with ~20 PowerPoint files and I'm curious to know the combined slide count.

I know you can right click and check the file info to get that files info, but it just says "(multiple values)" if I select multiple files (which is silly because selecting multiple media files will give you their total length).

I did a google but couldn't find any relevant info. Is there an easy way to do this? Or some sort of known script?

Thanks!

1

Michael Halpin has a Powershell script that does this. The original site is gone, but it is archived at https://web.archive.org/web/20180204011318/http://michaelhalpin.azurewebsites.net:80/use-powershell-to-get-numbers-of-slides-in-powerpoints/

Here is the script:

[CmdletBinding()]
[Alias()]
[OutputType([psobject])]
Param(
# The folder containing the files to count
[Parameter(ValueFromPipelineByPropertyName=$true,
        Position=0)]
$Path = 'C:\temp'
)
Add-Type -AssemblyName System.Windows.Forms
Add-Type -AssemblyName Office
Add-Type -AssemblyName Microsoft.Office.Interop.Powerpoint

Write-Verbose "Getting files from $path"
$files  = Get-ChildItem -filter *.ppt* -Path $Path

[psobject]$NumberOfSlides= @()

Foreach ($file in $files){
    $application = New-Object -ComObject powerpoint.application
    Write-Verbose "Opening $file" 
    $presentation = $application.Presentations.open($file.fullname)

    $slideCount =  New-Object System.Object
    $slideCount | Add-Member -type NoteProperty -name Name -value $file.name
    $slideCount | Add-Member -type NoteProperty -name Slides -value $presentation.Slides.Count

    #Introduce a slight wait so powerpnt.exe has time to process file
    Start-Sleep -Seconds 2
    $presentation.Close()

    $NumberOfSlides += $slideCount
    }

$NumberOfSlides

Write-Verbose "Cleaning up processes"
get-process powerpnt | Stop-Process
  • Thanks! This works great. It's a little slow and dirty because it opens up every pp file to get the slide count, but it gets the job done. – mo523 Jan 13 at 0:23

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.