I am trying to sort files on my NAS using the Terminal from Mac OSX. I am planning on using the following steps:
- create folder for specific year
- create folder for each month
- use the "Find" command to identify the year and month and move the file to relevant folder.
I have created 2 executable files for steps 1 to 2. I am still looking into setting up the 3rd file for step 3 but am running into problems.
For information:
File 1: "MakeMediaYearFolders.command" has the following code lines
#! /bin/bash
xargs -tI % mkdir % < MediaYearFolders.csv
where: "MediaYearFolders.csv" has the following lines
Media - 1999
Media - 2000
...
Media - 2020
File 2: "MakeMonthsFolder.command" has the following code lines
#! /bin/bash
cd /Users/Name/Desktop/DROBO TEST/2. SORTED/Media - 1999/
xargs -tI % mkdir % < MonthsFolders.csv
With "MonthsFolders.csv" has the following lines
01 - January
...
12 - December
File 3: currently has the following
#! /bin/bash
cp -fv /Users/name/Desktop/DROBO TEST/2. SORTED/MonthsFolders.csv /Users/name/Desktop/DROBO TEST/2. SORTED/Media - 1999
cp -fv /Users/name/Desktop/DROBO TEST/2. SORTED/MakeMonthsFolder.command /Users/name/Desktop/DROBO TEST/2. SORTED/Media - 1999
Cd /Users/name/Desktop/DROBO TEST/2. SORTED/Media - 1999
xargs -tI % mkdir % < MonthsFolders.csv
The problems I'm facing are multiple and I'm not quite sure how to tackle them:
- Problem 1: I'm unable to create a single file for steps 1 and 2 as I am not sure how to force the creation of the "months" folders in each "media - year" folder. when I tried, the files were simply not being copied and no error message was displayed. also, the "month" folders were being created in the root folder containing the "media - Year" folders
- Problem 2: I have to manually launch the creation of "months" folders for each "media - Year" folder. on top of things, I also have to copy the "CSV" file and executable file in each "media - Year " folder! really time consuming. I'm not quite sure how to force the creation of the "months" folders in each of the "media - Year". in fact, to create the folders, I have to launch the process using "./MakeMonthsFolder.command" from each folder.
- Problem 3: when using the "find" command, I am unable to move the relevant files. I use the following command:
find /Users/name/Desktop/DROBO\ TEST/1.\ SOURCE -name "201704*" -exec mv -v -- /Users/name/Desktop/DROBO\ TEST/1.\ SOURCE /Users/name/Desktop/DROBO\ TEST/Media\ -\ 2017/04\ -\ April
. I get the following message from the system:find: -exec: no terminating ";" or "+"
. I'm not quite sure how to interpret this let alone act upon it ;-)
Cherry on top of the cake: How do I get the mail for the message "You have new mail in /var/mail/name" ? basically I guess my question is how do I get there ?
Any help, suggestions ?
Thanks all