A copied directory is a new directory, so you need a new Id.
the children will also create a new directory for each child, so each one needs a new ID.
Original table content (indentation is to show subdirectories):
id 1 - pastaA - parentDirID: null
id 2 - pastaB - parentDirID: 1
id 3 - pastaC - parentDirID: 2
id 4 - pastaD - parentDirID: null
id 5 - pastaE - parentDirID: 4
id 6 - pastaF - parentDirID: 5
Now we'll copy the pastaE
down from pastaB
.
New directories pastaE
and pastaF
will be generated, therefore new IDs. Table contents after copying:
id 1 - pastaA - parentDirID: null
id 2 - pastaB - parentDirID: 1
id 3 - pastaC - parentDirID: 2
id 7 - pastaE - parentDirID: 2
id 8 - pastaF - parentDirID: 7
id 4 - pastaD - parentDirID: null
id 5 - pastaE - parentDirID: 4
id 6 - pastaF - parentDirID: 5
Conclusion
When you move a directory, you just change your parent ID .
When you copy a directory, a new directory is created, so you need a new ID. A new directory is also created for each subdirectory, and each of these new subdirectories points their parent ID to the newly created parent ID.
As for the files, new ones will also be created in a copy, so they will also receive new Ids and new parent Ids.
Another modeling option
Your current modeling can be quite difficult to maintain. I would do so:
Diretorios
id - caminho
1 - pastaA
2 - pastaA/pastaB
3 - pastaA/pastaB/pastaC
Arquivos
id - id_diretorio
1 - 1
2 - 1
3 - 2
It's simpler - it does not have a hierarchy of records, it will save a lot of code and simplify reading of table contents.