Duplicate folder structure, but not files (Mac)

UPDATED

in

by

Tags:


I had an interesting dilemma with Google Drive. We were switching as an organization from a shared Google Drive folder, to a Google Shared Drive. You are allowed to move files from Drive to Shared Drive (if you’re the owner…which is another story) but NOT folders, at least not at all permission levels.

I found a way to copy the folder structure, but no files. I just copied it to my desktop. Then I dragged that folder structure to the Shared Drive locally (Drive File Stream). Then, I was able to move Drive files into individual folders.

Source: StefanK on macscripter.net, 2009! Still worked.

Open Launchpad -> Script Editor -> Paste script -> Run script


set sourceFolder to (choose folder with prompt "choose source folder")
set sourceFolderName to name of (info for sourceFolder)
set destinationFolder to POSIX path of (choose folder with prompt "choose destination folder")
set folderList to paragraphs of (do shell script "/usr/bin/find " & quoted form of POSIX path of sourceFolder & " -type d \\( ! -path '*.app*' -and ! -path '*.rtfd*' -and ! -path '*.nib*' -and ! -path '*.mdimporter*' -and ! -path '*.xcode*' \\) ")
if folderList is not {} then
   set destinationFolder to destinationFolder & sourceFolderName & "/"
   do shell script "mkdir " & quoted form of destinationFolder
   set pathLength to ((length of POSIX path of sourceFolder) + 1)
   repeat with oneFolder in rest of folderList
       set restPath to text pathLength thru -1 of POSIX path of (oneFolder as Unicode text)
       do shell script "mkdir -p " & quoted form of (destinationFolder & restPath)
   end repeat
end if