Find missing folders paths in split hierarchies
I'd try something like this:


First, create a new table and copy the existing data there.
Then iterate, and in each iteration, remove the last node of each filepath (e.g.: 'A\B\C\D\E' becoming 'A\B\C\D') and add these new filepaths in the table, if they aren't already there.
Stop when an iteration doesn't produce new rows.


The initialization:

-- step 0
CREATE TABLE filepaths
  ( BaseDirID int NOT NULL,
    DirLevel int NOT NULL,
    DisplayPath varchar(1000) NOT NULL,   -- adjust the size according to your data,
    ReverseDisplayPath varchar(1000) NOT NULL,
    Iteration int NOT NULL,
    PRIMARY KEY (Iteration, ReverseDisplayPath),
    UNIQUE (ReverseDisplayPath)
  ) ;

INSERT INTO filepaths
  ( BaseDirID, DirLevel, DisplayPath, ReverseDisplayPath, Iteration )
SELECT
    BaseDirID, DirLevel, DisplayPath, reverse(DisplayPath), 0
FROM 
    existing_table ;


And the iterations:

DECLARE @new_items bigint ;
DECLARE @iter int ;
SET @iter = 0 ;

-- repeat
repeat:     
    INSERT INTO filepaths
        (BaseDirID, DirLevel, DisplayPath, ReverseDisplayPath, Iteration)
    SELECT DISTINCT
        f.BaseDirID, f.DirLevel - 1, reverse(r.rdp), r.rdp, @iter + 1
    FROM 
        filepaths AS f
      CROSS APPLY
        ( SELECT substring(f.ReverseDisplayPath, 
                           1 + charindex('\', f.ReverseDisplayPath), 
                           1000) AS rdp
        ) AS r
    WHERE 
          f.Iteration = @iter
      AND f.DirLevel &gt; 1 
      AND NOT EXISTS
          ( SELECT *
            FROM filepaths AS ex
            WHERE ex.ReverseDisplayPath = r.rdp
          ) ;
    SET @new_items = @@ROWCOUNT ;

    SET @iter = @iter + 1 ;
    -- until new_items = 0
    IF (@new_items &gt; 0) GOTO repeat; 


After the process is finished, you can get only the missing filepaths with a simple query:

SELECT DisplayPath FROM filepaths 
WHERE Iteration &gt; 0 
ORDER BY DisplayPath ;


Tested in dbfiddle.uk.

The reverse strings are not strictly needed but they simplify the splitting of the strings. You could go without them (and a bit more complex code). You could also have only the reverse paths stored in the new filepaths table and when the iterations are complete, reverse them again into the target table (the existing one I guess or wherever you want them to go).

The whole thing could also be done with a single pass - using a recursive CTE - but I don't know if that would be more or less efficient.