..

Automated creation/cloning of a folder structure for several locales

Create a text file (i.e., Locales.txt) containing the names of the subfolders that you wish to create and copy it to the parent folder of your new folder structure.

Type the names one in each line.

For example:

ca_ES
cs_CZ
da_DK
de_DE
el_GR
es_ES
zh_CN
zh_TW

1. Open a Terminal window.

2. Type the following command:

sed '/^$/d;s/ /\//g' Locales.txt | xargs mkdir -p

3. Type the command

ls

to verify the folder structure. The output should be similar to:

total 8
drwxr-xr-x  11 jlegat  staff   374 Mar  5 15:34 .
drwx------+ 67 jlegat  staff  2278 Mar  5 15:34 ..
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 ca_ES
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 cs_CZ
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 da_DK
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 de_DE
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 el_GR
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 es_ES
-rw-rw-r--   1 jlegat  staff    47 Mar  5 15:32 skel.txt
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 zh_CN
drwxr-xr-x   2 jlegat  staff    68 Mar  5 15:34 zh_TW

sed(1) Mac OS X Manual Page

xargs(1) Mac OS X Manual Page

mkdir(2) Mac OS X Developer Tools Manual Page

Alternatively, you can clone an existing folder structure with empty subfolders – just the folder tree, no files:

1. Open a Terminal window.

2. Navigate to the folder structure you want to copy.

3. Type the following command to create a list of the folders:

find . -type d > folder_list.txt

4. Copy the folder_list.txt file to the new destination parent folder.

5. Type the following command to recreate the structure in your new destination parent folder:

cat folder_list.txt | xargs mkdir

find(1) Mac OS X Manual Page

cat(1) Mac OS X Manual Page