Copy folder structure and make new folder?

Hello!

Suppose I have a folder structure on my harddrive as:

Main Folder
-- 01_FirstFolder
  --> 1stSubFolder
  --> 2ndSubFolder
  --> 3rdSubFolder
-- 02_SecondFolder
  --> 1stSubFolder
  --> 2ndSubFolder
  --> 3rdSubFolder

How would I go about copying the folder structure, to make a new “New Main Folder” with the exact same folder structure inside? Just without any of the previous file content.

Kind regards

Directly adapated from the example in the walkdir docs (but have not tested!):

for (root, dirs, files) in walkdir(sourceDir)
     for dir in dirs
          mkpath(joinpath(tgDir, dir))
     end
end
1 Like