SharePoint – Deleting all global templates via stsadm

Deleting all global sharepoint templates has been a real pain for me – especially when I’ve had 50+ registered. There is no switch on stsadm to delete all templates – you can only delete them one-by-one. I hence thought id brush up my dos scripting this lunchtime and write a command to facilitate deleting of all global templates registered through stsadm…

stsadm -o enumtemplates > templatelist.txt & for /F "tokens=1" %i in (templatelist.txt) do stsadm -o deletetemplate -title %i & del templatelist.txt

Note that this can actually go on three lines…

stsadm -o enumtemplates > templatelist.txt
for /F "tokens=1" %i in (templatelist.txt) do stsadm -o deletetemplate -title %i
del templatelist.txt

Note that either stsadm must be in the path, or you must be in C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\BIN (or equivalent) when running this command. Remember to do an iisreset when run.

Also note that I believe this works in both sharepoint 2003 / wss 2 and sharepoint 2007 / wss 3

You May Also Like

About the Author: rnowik

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.