我正在将文件从网络驱动器迁移到SharePoint。迁移工具为以csv格式迁移的每个文件和文件夹生成报告。条目按随机顺序排列。我想从报告中生成所有文件夹的csv提取,并按路径对它们进行排序。
例如(文件夹名称仅供参考)
https://mytenant/site/library/folder1
https://mytenant/site/library/folder1/folder12
https://mytenant/site/library/folder1/folder12/folder13
https://mytenant/site/library/folder2
https://mytenant/site/library/folder2/folder22
https://mytenant/site/library/folder2/folder22/folder23
使用powershell可以吗?
将这些文件迁移到SharePoint时,由于Windows限制为256个字符,因此其中某些文件无法在IE11的资源管理器视图中打开。
我想找出导致此问题的文件夹,并找出重命名时使用哪些长名称的文件夹可以大大减少此问题。
答案 0 :(得分:0)
如果我正确理解了问题和您的评论,这可能会有所帮助:
$result = Import-Csv -Path 'D:\FilesAndFolders.csv' |
Where-Object {$_.Type -eq 'Folder'} |
Select-Object -ExpandProperty Path |
Sort-Object |
ForEach-Object {
[PSCustomObject]@{
'Path' = $_
'Length' = $_.Length
}
}
# output on screen
$result | Format-Table -AutoSize
# output to new CSV file
$result | Export-Csv -Path 'D:\PathLengths.csv' -Force -NoTypeInformation
它读取报告CSV,仅获取类型为“文件夹”的对象,并对路径名称的结果字符串数组进行排序。作为输出,它将向每个文件夹路径添加Length
属性。
以您的示例为例,屏幕上的输出为:
Path Length ---- ------ https://mytenant/site/library/folder1 37 https://mytenant/site/library/folder1/folder12 46 https://mytenant/site/library/folder1/folder12/folder13 55 https://mytenant/site/library/folder2 37 https://mytenant/site/library/folder2/folder22 46 https://mytenant/site/library/folder2/folder22/folder23 55