I'm a reporter who works with data sets. Every time I receive a new data set, I do two things immediately: Duplicate the file(s) and lock the originals.
I want to automate that process. By altering a shell script I use to create nested folders for reporting projects and stringing it together with a bunch of commands, I was able to achieve the basic functionality, but it is messy. I would be grateful for your help in streamlining.
Here's what I'm doing now (bear with me and I promise to be as clear as possible):
I download the data to a Desktop folder called "DataInbox" where I also have the following shell script, saved as newdata.sh:
#!/bin/bash
if [[ -z "${1}" ]]; then
die "FolderName Required"
fi
/bin/mkdir -p ~/Desktop/DataFarm/$1/{ProtectedOrig,Data}
echo -n "---Data Folder Setup
---Data Introduction
---Data Audit/Manipulation
---Data Queries" > ~/Desktop/DataFarm/$1/Data/DataJournal.txt
By executing bash newdata.sh DirectoryName
I create a directory with the subfolders "Data" and "ProtectedOrig" and a text file called "DataJournal.txt" with four headings built in.
Inside the "DataInbox" directory I run this mess, only strung together with &&
:
$ ditto NewData/ NewDataCopy
$ bash newdata.sh DirectoryName
$ mv NewData/ /Users/JSG/Desktop/DataFarm/DirectoryName/ProtectedOrig/NewData
$ mv NewDataCopy/ /Users/JSG/Desktop/DataFarm/DirectoryName/Data/NewDataCopy
$ chflags -R uchg /Users/JSG/Desktop/DataFarm/DirectoryName/ProtectedOrig/
Like I said, I'd like to streamline this. In fact, what I'd really like to do is turn the whole thing into a shell script, and I'm struggling to make it work. Thank you in advance from an eager novice.