How do I copy folder/directory structure without copying the contents?

I need to copy A LOT of folders over but I do not want any of the files to come with them, just the names and structure of the folders. I am not the most technologically savvy so I don't even know where to begin or what program to use, then what codes to use after that.

Any help would be greatly appreciated as I need to get this done as soon as possible.

Thank you!

Has invited:

howapple - hello

Favor from:

The following AppleScript/Ruby solution will duplicate a source folder hierarchy to a destination folder hierarchy with no files copied. It is very quick. Tested on El Capitan 10.11.4 with System Ruby v2.0.0p648.

The script will prompt for a source folder, and again for a destination folder. If the destination folder does not exist, then use the New Folder button on the panel, and give the new folder a name. This will open into a blank new folder, so just select choose, and everything will get duplicated into the new folder. You can choose a different source folder, and specify the existing destination folder, and the new hierarchy will be duplicated in addition to existing structure.

Copy and paste the following script code into your (launchpad : Other : Script Editor). Click the hammer icon on the toolbar, and then just run ▸ it. I would recommend saving the script first as applescript text, and then following that with the option key to Save As… and make it either a script bundle, or application on your Desktop. This way, you won't lose the original script text.

Code:

set dest_string to "Choose a destination folder. If it does not exist," & return & ¬

"make a new folder (give it a name), and choose the blank folder"

try

set srcfolder to POSIX path of (choose folder with prompt "Choose a source folder:")

set destfolder to POSIX path of (choose folder with prompt dest_string)

on error errmsg number errnbr

if errnbr = -128 then

display dialog "User cancelled."

end if

return

end try

set argvector to srcfolder's quoted form & space & destfolder's quoted form

if (dupe_folder(argvector) as boolean) is equal to true then

display dialog "New folders structure complete:" & return & destfolder as text

else

display dialog "Ruby structure duplication process has failed."

end if

return

on dupe_folder(args)

return do shell script "ruby <<'EOF' - " & args & "

#!/usr/bin/ruby

# coding: utf-8

# attribution: Craig Williams at MacScripter: http://macscripter.net/viewtopic.php?id=31401

require 'find'

require 'fileutils'

source, dest = ARGV

IGNORE = ['.app', '.scptd', '.rtfd', '.pages']

Find.find(source) do |item|

next if !File.directory?(item) || item == source

Find.prune if IGNORE.include?(File.extname(item))

FileUtils.mkdir_p(dest + item.gsub(source, ''))

end

# send the Ruby block status back to AppleScript as true or false

puts $?.success?

EOF"

end dupe_folder

To reply to a question, please Login or registered