0

I have a directory full of powerpoint presentations(pptx). I'm trying to find the presentations that have the word "December" in them. In my Mac I could use grep, but in Windows I've been trying to use Powershell and the command prompt and it is not working.

I tried searching other posts, but what I found were things like this" other post

I tried using findstr /s /i /m "\<december.*" *.* on the command prompt, but it only returned one .doc and none of the pptx files. I know I have some pptx files with the word "december" in them.

I also tried the following in Powershell:

Location = "C:users\mary\desktop
SearchStr = "december"
Sel = Select-String -pattern SearchStr -path Location
If (Sel -eq null)
{
    write-host "Location does not contain SearchStr
}
Else
{
    write-host "Found 'n Sel"
}
Write-host "end"

And I get that the file cannot be read. I want it to look at the directory.

Any help would be much appreciated.

  • 1
    "*I tried searching other posts, but what I found were things like this" other post*" - and .. did you read that other post? Because Ryan's comment on the answer explains why you can't do that. pptx files are compressed. See https://stackoverflow.com/a/1249827/478656 as well. – TessellatingHeckler May 02 '18 at 05:50
  • Google could be your friend, my [very first result](http://community.idera.com/powershell/ask_the_experts/f/learn_powershell-12/7490/text-searching-a-powerpoint-document-for-a-string) with the keywords `powershell search ppt` looks promising –  May 02 '18 at 06:48
  • @TessellatingHeckler - My files are not zipped. I don’t need to unzip them. This is a very foreign concept to me. –  May 03 '18 at 13:38
  • @LotPings - If you read the post carefully you’ll see that this post is from someone having issues making his code work and asking for help. He has no replies. I need something that works not more code that does not work. –  May 03 '18 at 13:40
  • I'm not aware of a Powershell module for poweroint to ease working with ppt(x) files without having MsOffice installed like `ImportExcel` or `PSExcel` for Excel. So you have to use the COM Object and kinda remote control PowerPoint from PowerShell. There are examples for Word and Excel, less for PowerPoint. If you are used to vba for powershell you know the objects,methods,enumerations powerpoint exposes and can use them also via powershell - I'm not. Clear is your simplistic grep approach can't work and if you are really interrested I pointed out a way you could go with some effort. –  May 03 '18 at 14:42
  • @dev_2018 .pptx files (and other Office .docx and .xlsx formats) are compressed internally, they are roughly .zip files by another name. Copy a `.pptx` file and rename it to `.zip` and you'll see that you can open it in a Zip tool (7zip, WinZip, etc). This means there is no asy way to find plain text by reading the file data with any text processing tool (get-content, select-string, grep, etc), the file content must be decompressed first. – TessellatingHeckler May 03 '18 at 19:58

1 Answers1

2

A pptx file is not a plain text file. It is actually a zip file (use 7-Zip to extract one and see). Searching the way you are will not yield very good results, if any at all. As a test, open the pptx in Notepad++ and see what it looks like. Perhaps you can adapt https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/01/find-all-word-documents-that-contain-a-specific-phrase/ to do what you want for pptx, or search another solution now that you know plain text will not work.

Kory Gill
  • 6,993
  • 1
  • 25
  • 33