jeudi 17 novembre 2022

Rnadomly allocate files to folders in python

I have a list with 200 unique identifiers and I want to randomly move this identifiers to different folders.

Each folder to contain 20 unique identifiers with 1 identifier appearing in other folders.

So say a folder 1 has 19 identifiers, I want to copy 1 identifier from folder 1 to folder 3 so that folder 3 to have 20 images.

Then I will copy one identifier from folder 2 which has 19 identifiers to folder 4 and the process continues like that upto the end.

The last folder being that it wont have any remaining folder to copy identifier to , I will copy identifier from last folder to folder one and that should complete the circle.

Here is how this identifiers look like:

list_ids = [04120, 04121,04125, 05100, 05101, ....]

Not that this process, I will just be copying identifiers from one folder to another, not moving them.

End result is each folder should have 20 identifiers but among the 20, one Identifier has been repeated from another folder.

folder structure : folder 1 - 20 ids (1 id repeated from another folder)
                   folder 2 - 20 ids (1 id repeated from another folder)
                   folder 3 - 20 ids (1 id repeated from another folder)
                   folder 6 - 20 ids (1 id repeated from another folder)
                   folder 5 - 20 ids (1 id repeated from another folder)

I am struggling on how to write a python code to randomly create this identifiers. Any help will be appreciated




Aucun commentaire:

Enregistrer un commentaire