mercredi 2 décembre 2015

Batch move folder with random name

I need to move folders and their structure to somewhere else. I don't know the name of those folders. Move command is denied & copy doesn't keep structure in this state :

    @echo on
    for /D %%b in (*) do XCOPY "%%~fb" "C:\Users\*Username*\Desktop\New files" /Y /E 
    timeout /t -1

This is what I get :

    sourcefolder                           destinationfolder
      | Randomfolder1                         | Randomfolder2
      |    |  Randomfolder2                   |    \randomfile2.txt 
      |    |     \randomfile2.txt             \randomfile1.txt
      |    \randomfile1.txt
      \moverandomfolders.bat                  

Obviously I miss the name of the new folder in its new directory to keep the same structure. How do you add that random name to the new path ? I'd also need something to delete folders from their original path after they have been copied.

    rd /s /q "*random folder name*"




Aucun commentaire:

Enregistrer un commentaire