Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

automator: duplicate folder names but not the content - photography

I'm a photographer for a large fashion brand. I have dozens of folders with 30 photographs per folder. I need to create folders on a server with the same folder names - but I don't want the content copied over - I want to automate this task of creating duplicate folders but the folders need to be empty. After that I'm going to try to automate the task of exporting only selected images from Adobe Bridge, but that's another thread on a different site I assume. thanks in advance! Michelle in NYC

MacBook Pro, Mac OS X (10.6.8)

Posted on Oct 24, 2013 12:09 PM

Reply
Question marked as Best reply

Posted on Oct 24, 2013 7:28 PM

This is trivial to do with 'pure' AppleScript, but tricky with Automator.


The following AppleScript will prompt you for two directories - the top level of the source directories to copy, followed by the location you want to replicate the directories to.


It then iterates through the source directories creating a matching tree in the destination directory (ewithout files)


set startDir to choose folder with prompt "Select the Original directory to replicate"

set destDir to choose folder with prompt "Select where to create the new folders"


tell application "Finder"

set sourceDirs to every folder of startDir


end tell


repeat with eachDir in sourceDirs

my replicateDir(eachDir, destDir)

end repeat


on replicateDir(sourceDir, destDir)

set dirName to name of sourceDir

tell application "Finder"

set thisDir to makenewfolderatdestDirwith properties {name:dirName}

set subDirs to every folder of sourceDir

repeat with eachDir in subDirs

my replicateDir(eachDir, thisDir)

end repeat

end tell

end replicateDir


Either use AppleScript Editor to create and run the script, or add it to a 'Run AppleScript' Automator action.

4 replies
Question marked as Best reply

Oct 24, 2013 7:28 PM in response to Michelle Mcdonald

This is trivial to do with 'pure' AppleScript, but tricky with Automator.


The following AppleScript will prompt you for two directories - the top level of the source directories to copy, followed by the location you want to replicate the directories to.


It then iterates through the source directories creating a matching tree in the destination directory (ewithout files)


set startDir to choose folder with prompt "Select the Original directory to replicate"

set destDir to choose folder with prompt "Select where to create the new folders"


tell application "Finder"

set sourceDirs to every folder of startDir


end tell


repeat with eachDir in sourceDirs

my replicateDir(eachDir, destDir)

end repeat


on replicateDir(sourceDir, destDir)

set dirName to name of sourceDir

tell application "Finder"

set thisDir to makenewfolderatdestDirwith properties {name:dirName}

set subDirs to every folder of sourceDir

repeat with eachDir in subDirs

my replicateDir(eachDir, thisDir)

end repeat

end tell

end replicateDir


Either use AppleScript Editor to create and run the script, or add it to a 'Run AppleScript' Automator action.

Oct 25, 2013 9:35 AM in response to Camelot

So is this the only action I put into Automator? And then I can Save As an application and use it to drop onto? Will it prompt me to direct it to the first folder and then to the destination? I've never used Automator (only played around) so I don't really know what I'm doing. And as far as AppleScripts, I only wish I knew how these worked. Really appreciate the help. - Michelle

Oct 25, 2013 9:47 AM in response to Michelle Mcdonald

So is this the only action I put into Automator?


The script is (conceptually) complete and does not need any additional workflow actions.


And then I can Save As an application and use it to drop onto?


As written, this is not a drop-aware application - that is, dropping items on the script/application icon will have no effect (other than launching the app and having it do its thing). There is no mechanism (currently) to respond to items dropped on the icon. How would you envision this working?


Will it prompt me to direct it to the first folder and then to the destination?


As written, it will always ask for two directories - the source directory that you want to replicate the structure (but not contents) of, and the location where you want to replicate it.

Note that it replicates the *content* of the source directory, not the directory itself. That's a trivial change if you want it to do that.

automator: duplicate folder names but not the content - photography

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.