基于SharePoint的批量重命名文件,该文件根据元数据字段进行过滤 [英] Bulk renaming file based on SharePoint that is filtered based on metadata field
问题描述
嘿,
我正在使用SharePoint脚本,它将使我能够批量更新董事会站点文档库的文件名.
I am working on a SharePoint script that will enable me to bulk update file names for a board site document library.
我们每个月都会根据模板制作52个单词的文档,并且希望简化此过程.我有一个脚本,可以让我在整个库中重命名文件,但是库中有4000多个文档,希望过滤 这适用于列在名为纸张-草稿的列中的特定文档 文档类型.
We produce 52 word documents based on a template every month and would love to stream line this process. I have a script that will enable me to rename a file within the entire library but we have over 4000 documents in the library and would love to filter this to particular documents that are within labelled Papers - draft within a column called Document Type.
我正在使用的代码在下面,并且只需要有关如何在此脚本中添加过滤器行的帮助.
The code that I am working with is below, and just need help on how to add the filter line to this script.
#Get the Web
$Web = Get-SPWeb "http://example.com/FilePlan/BoardAdmin"
#Get the List
$List = $Web.Lists["Board Administration Documents"]
#Iterate Through All List Items
foreach($ListItem in $List.Items)
{
if($null -ne $ListItem.File) #Exclude Document Sets
{
Write-Host "Checking $($ListItem.Name)..."
#Check out, if Require checkout is enabled
#$ListItem.File.CheckOut()
#Replace "Copy of " with ""
$ListItem["Name"] = $ListItem["Name"].replace("Copy of ","")
#Update the changes
$ListItem.Update()
#$ListItem.File.CheckIn("Updated the File Name")
}
}
推荐答案
if(
ListItem ["DocumentType"] -eq"Paper-draft") { 继续; }
ListItem["DocumentType"] -eq "Paper - draft") { continue; }
类似于上面的代码,您需要调试.
something like above code, you need to debug.
这篇关于基于SharePoint的批量重命名文件,该文件根据元数据字段进行过滤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!