[Mac OS X] How can we share a number of files belonging to the same folder, in several folders

Tutorial is addressed to users of MAC OS X, who need to share a large number of files from a folder, in multiple folders.

In our case, the problem looks as follows:

We have a folder “PSD” which contains 2105 files, and of these 2105 files we want to create folders that do not contain each more than 300 files.

List Folder Files Mac OS X

To achieve this, the simplest and most handy is command line FROM Terminal.

1. We open Terminal And we browse the folder in which are the files we want to share. In our case the order will be:

cd /Volumes/Stealth/Graphics/PSD

2. We visualize the number of files and folders existing in the current location:

ls -l | wc -l

Before moving on to step 3 it is good to make sure that there are no blocked files in the folder (locked files). If they exist, during the execution we will receive error messageOperation not permitted“. With the help of the order“chflags -R nouchg *” We will unlock all the files in the current location (Unlock multiple files in Mac OS X).

3. The command line by which we divide the total files from the current folder, in folders containing a defined number of files:

i=0; for f in *; do d=psd_$(printf %03d $((i/300+1))); mkdir -p $d; mv "$f" $d; let i++; done

Where “psd_” is the prefix of folders that will be created, and “300” is the number of files maximum per folder. These parameters can be modified according to your preferences.

Here's what this tutorial looks like in the terminal:

Screen Shot 2015-01-16 at 21.53.44
Stealth Settings – Split a folder with thousands of files into multiple sub-folders.

This tutorial has been tested and realized on MacBook Pro cu OS X Yosemite.

Founder and editor Stealth Settings, din 2006 pana in prezent. Experienta pe sistemele de operare Linux (in special CentOS), Mac OS X , Windows XP > Windows 10 si WordPress (CMS).

Home Your source of IT tutorials, useful tips and news. [Mac OS X] How can we share a number of files belonging to the same folder, in several folders
Leave a Comment