Tigraine
Daniel Hoelbling talks about .NET

Howto get rid of *.onetoc2 files using Powershell

September 1st, 2009 . by Daniel Hölbling

Today I did one small mistake when trying to open a command-line window on my source folder: Instead of hitting “Open command window here” I accidentally clicked “Open as OneNote notebook”.

Quite innocently, OneNote opened, I closed it. Everything was fine. Until I did a hg status:

? lib\OneNote Inhaltsverzeichnis.onetoc2
? lib\castle\OneNote Inhaltsverzeichnis.onetoc2
? lib\elmah\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\extensions\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\extensions\common\2.0\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\extensions\common\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\common\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\common\neutral\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\mono\1.0\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\mono\2.0\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\mono\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\net\1.0\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\net\1.1\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\net\2.0\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\lib\net\OneNote Inhaltsverzeichnis.onetoc2
? lib\nant\schema\OneNote Inhaltsverzeichnis.onetoc2
? lib\sqllite\OneNote Inhaltsverzeichnis.onetoc2
? lib\xunit\OneNote Inhaltsverzeichnis.onetoc2

Oh snap! OneNote just placed a table of contents file in every subdirectory of my lib folder! And, best of all, despite the setting “show all hidden” I couldn’t see those files through my explorer.
Also, a del /s *.onetoc2 did not remove the files.

Google to the rescue, I’m not the first to make that mistake, and Richard Siddaway also posted a way how to remove those using Powershell:

Get-ChildItem -Filter "*.onetoc2" -Force -Recurse | Remove-Item –Force

I’m quite shocked. I’ve been using the regular windows command line for quite some time now, and I have to say: Microsoft really has something going here with Powershell. It works really nice, and once you get a hang of the syntax it is really cool to work with.


View Comments to “Howto get rid of *.onetoc2 files using Powershell”

  1. comment number 1 by: Cesar

    del *.onetoc2 /s /ahs

  2. comment number 2 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  3. comment number 3 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  4. comment number 4 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  5. comment number 5 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  6. comment number 6 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  7. comment number 7 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  8. comment number 8 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  9. comment number 9 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  10. comment number 10 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  11. comment number 11 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  12. comment number 12 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  13. comment number 13 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  14. comment number 14 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  15. comment number 15 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  16. comment number 16 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  17. comment number 17 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  18. comment number 18 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  19. comment number 19 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  20. comment number 20 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  21. comment number 21 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  22. comment number 22 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  23. comment number 23 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  24. comment number 24 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

  25. comment number 25 by: NIck

    Can someone tell me how to disable onenote from creating these files in the first place?

Leave a Reply

Name

Mail (never published)

Website

blog comments powered by Disqus