0

I have few folders and sub-folders in SharePoint document library. I need to compare if the file names in all folders and sub-folders are unique or not.

Is there any PowerShell script which will help me?

1

You will have to query the library using caml query, and specifically use

<FieldRef Name='FsObjType'/><Value Type='Text'>0</Value>

in the query set the ViewAttributes of the query object to 'RecursiveAll'.

Then you can use the item collection to check for duplicates. And this can be done using powershell just Google it.

1

The solution below is not optimal but easy to use:

  1. Download and install the SPOMOD
  2. Run Connect-SPOCSOM
  3. Run:

    $files=(Get-SPOListItems alib -IncludeAllProperties $true -Recursive)
    foreach($file in $files){ foreach ($file2 in $files){ if ($file.FileLeafRef -eq $file2.FileLeafRef -and $file.ID -ne $file2.ID) {$file.FileRef}}}
    

enter image description here

alib is the name of your library

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.