Tigraine

Daniel Hoelbling-Inzko talks about programming

Howto get rid of *.onetoc2 files using Powershell

Posted by Daniel Hölbling on September 1, 2009

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.

Filed under personal
comments powered by Disqus

My Photography business

Projects

dynamic css for .NET

Archives

more