There are many PDF files in our project that are manually added to the media library.
I see that some of them have the template - /sitecore/templates/System/Media/Versioned/Pdf
and some others - /sitecore/templates/System/Media/Unversioned/Pdf
Why does this happen. I'm sure the author would not select any settings to have it uploaded as 'Versioned'.And this happend with image files too.
I would like to change all
versioned pdf
tounversioned pdf
.
When I try this power shell script, it throws an error:
$master = [Sitecore.Configuration.Factory]::GetDatabase("master");
$entryTemplate = $master.Templates["/sitecore/templates/System/Media/Unversioned/Pdf"];
cd master:"\media library\Files\Test";
Get-ChildItem -recurse | ForEach-Object { if ($_.TemplateName -eq "Pdf") { $_.ChangeTemplate($entryTemplate) } };
Exception calling "ChangeTemplate" with "1" argument(s): "Value cannot be null. Parameter name: template" At line:8 char:76 + ... ($.TemplateName -eq "Pdf") { $.ChangeTemplate($entryTemplate) } }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException
Exception calling "ChangeTemplate" with "1" argument(s): "Value cannot be null. Parameter name: template" At line:8 char:76 + ... ($.TemplateName -eq "Pdf") { $.ChangeTemplate($entryTemplate) } }; + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException
Using Sitecore 8.2 update 3
"
characters around"master:\media library\files\Test"
?$entryTemplate = $master.Templates["System/Media/Unversioned/Pdf"];