NAS Stats CODE1

NAS Stats CODE 1

Sep 16, 2020 rap

This code run runs in a terminal window on MAC that has Internet access. It produces about 150 lines of code in the terminal window that can be converted into a markdown table.

# find number of files in directory
# Sep 16, 2020
# source: /Users/rproctor/Dropbox-ANRL/Dropbox/_Workflow_Patron_NAS/Script/MASTER - NAS-Report-Status-KIND.txt

### Step 1)  Login to SSH on NAS
ssh admin@72.188.170.26 -p 22

### Step 2)  Set variable RS to location to write Report Stats and initialize
RS="/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/Report_Stats/2020-09-11"
echo "#### NAS Stats for 2020-09-11-Thu-" > "$RS"
echo "#### Report of number of records in folders on NAS" >> "$RS"
echo "#### script: /Users/rproctor/Dropbox-ANRL/Dropbox/_Workflow_Patron_NAS/Script/NAS-Report-Status.txt" >> "$RS"

### Step 3)  Shell commands to get number if items in each location
echo "Kind::.mp3" >> "$RS"
echo "ANRL Audio Archive: /volume1/ANRL SYNC/ANRL Audio Archive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Audio Archive"
ls -1 | grep mp3 | wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "ANRL Book Archive: /volume1/ANRL SYNC/ANRL Book Archive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Book Archive" 
ls -1 | grep .pdf | wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "ANRL Magazine Archive/Foreign: /volume1/ANRL SYNC/ANRL Magazine Archive/Foreign" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Magazine Archive/Foreign"
find . -name "*.pdf"| wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS" 
echo "ANRL Magazine Archive/United States: /volume1/ANRL SYNC/ANRL Magazine Archive/United States" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Magazine Archive/United States"
find . -name "*.pdf"| wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "ANRL Newsletter Archive: /volume1/ANRL SYNC/ANRL Newsletter Archive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Newsletter Archive"
find . -name "*.pdf"| wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "ANRL Newsletter Archive/Active: /volume1/ANRL SYNC/ANRL Newsletter Archive/Active" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Newsletter Archive/Active" 
find . -name "*.pdf"| wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "ANRL Newsletter Archive/Inactive: /volume1/ANRL SYNC/ANRL Newsletter Archive/Inactive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Newsletter Archive/Inactive"
find . -name "*.pdf"| wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "ANRL Nudist Clubs & Organizations: /volume1/ANRL SYNC/ANRL Nudist Clubs & Organizations" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Nudist Clubs & Organizations" 
find . -name "*.pdf"| wc -l >> "$RS"

echo "Kind::DIR" >> "$RS"
echo "ANRL Nudist Organization Archive - Folders - Org names: /volume1/ANRL SYNC/ANRL Nudist Organization Archive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Nudist Organization Archive" 
ls -l | wc -l >> "$RS"

echo "Kind::.mp4" >> "$RS"
echo "ANRL Videos - .mp4: /volume1/ANRL SYNC/ANRL Videos: /volume1/ANRL SYNC/ANRL Videos" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Videos"
ls -1 | grep .mp4 | wc -l >> "$RS"

echo "Kind::.mv4" >> "$RS"
echo "ANRL Videos - .m4v: /volume1/ANRL SYNC/ANRL Videos: /volume1/ANRL SYNC/ANRL Videos" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Videos"
ls -1 | grep .m4v | wc -l >> "$RS"

echo "Kind::DIR" >> "$RS" 
echo "ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Who's Who Archive"
ls -1 | grep ^d | wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS" 
echo "ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Who's Who Archive"
ls -1 | grep .pdf | wc -l >> "$RS"

echo "Kind::.mp4" >> "$RS"
echo "Gary Nichols - Video Conversion - .mp4: /volume1/homes/Gary Nichols/Drive: /volume1/homes/Gary Nichols/Drive" >> "$RS"
cd "/volume1/homes/Gary Nichols/Drive"
ls -1 | grep .mp4 | wc -l >> "$RS"

echo "Kind::.m4v" >> "$RS"
echo "Gary Nichols - Video Conversion - .m4v: /volume1/homes/Gary Nichols/Drive: /volume1/homes/Gary Nichols/Drive" >> "$RS"
cd "/volume1/homes/Gary Nichols/Drive"
ls -1 | grep .m4v | wc -l >> "$RS"

echo "Kind::.mp3" >> "$RS"
echo "Gary Nichols - Video Make .mp3 Nested - .mp3: /volume1/ANRL SYNC/ANRL Audio New" >> "$RS"
cd "/volume1/ANRL SYNC/ANRL Audio New"
find . *.mp3 | wc -l >> "$RS"

echo "Kind::.mp3" >> "$RS"
echo "Bob: ANRL Audio - rap .mp3: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Audio - rap/Audio-Adjusted" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Audio (rap)/Audio-Adjusted"
ls -1 | grep .mp3 | wc -l >> "$RS"

echo "Kind::.mp3" >> "$RS"
echo "Bob: ANRL Audio Tape MP3: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Audio - rap/Audio-Adjusted" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Audio Tape MP3"
ls -1 | grep .mp3 | wc -l >> "$RS"

echo "Kind::.mp3" >> "$RS" 
echo "Bob: ANRL Board Meeting MP3: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Board Meeting MP3" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Board Meeting MP3"
ls -1 | grep .mp3 | wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "Bob: ANRL Board Meeting Notes: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Board Meeting Notes" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Board Meeting Notes"
ls -1 | wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "Bob: ANRL Cove Player Programs: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Cove Player Programs" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Cove Player Programs"
ls -1 | wc -l >> "$RS"

echo "Kind::.fmp12" >> "$RS" 
echo "Bob: ANRL Database Golden Conflicted Copies: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Database Golden Conflicted Copies" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Database Golden Conflicted Copies"
ls -1 | wc -l >> "$RS"

echo "Kind::.mp4" >> "$RS"
echo "Bob: ANRL-Videos: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL-Videos" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL-Videos"
ls -1 | grep .mp4 | wc -l >> "$RS"

echo "Kind::.pdf" >> "$RS"
echo "Bob: Audio Transcripts of tapes by Evan Nix: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/Audio Transcripts of tapes by Evan Nix" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/Audio Transcripts of tapes by Evan Nix"
ls -1 | grep .pdf | wc -l >> "$RS"

echo "Kind::.fmp12" >> "$RS" 
echo "Bob: FileMaker BU Archive: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/FileMaker BU Archive" >> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/FileMaker BU Archive"
ls -1 | wc -l >> "$RS"
 
echo "Kind::.md" >> "$RS" 
echo "Source code for web pages: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL_PAGES">> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL_PAGES"
find . -name "*.md" | wc -l >> "$RS"

echo "Kind::.jpg" >> "$RS" 
echo "JPG data from scanned Books: /volume1/homes//admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data Books">> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data Books"
find . -name "*.jpg" | wc -l >> "$RS"

echo "Kind::.jpg" >> "$RS" 
echo "JPG data from Foreign Magazines: /volume1/homes//admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data Foreign Magazines">> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data Foreign Magazines"
find . -name "*.jpg" | wc -l >> "$RS"

echo "Kind::.jpg" >> "$RS" 
echo "JPG data from US Magazines: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data US Magazines">> "$RS"
cd "/volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data US Magazines"
find . -name "*.jpg" | wc -l >> "$RS"

### Step 4) write $RS to terminal and exit SSH
cat "$RS"
exit

NAS Stats CODE 2

#### NAS Stats for 2020-09-11-Thu-
#### Report of number of records in folders on NAS
#### script: /Users/rproctor/Dropbox-ANRL/Dropbox/_Workflow_Patron_NAS/Script/NAS-Report-Status.txt
Kind::.mp3
ANRL Audio Archive: /volume1/ANRL SYNC/ANRL Audio Archive
123
Kind::.pdf
ANRL Book Archive: /volume1/ANRL SYNC/ANRL Book Archive
144
Kind::.pdf
ANRL Magazine Archive/Foreign: /volume1/ANRL SYNC/ANRL Magazine Archive/Foreign
7183
Kind::.pdf
ANRL Magazine Archive/United States: /volume1/ANRL SYNC/ANRL Magazine Archive/United States
4904
Kind::.pdf
ANRL Newsletter Archive: /volume1/ANRL SYNC/ANRL Newsletter Archive
7069
Kind::.pdf
ANRL Newsletter Archive/Active: /volume1/ANRL SYNC/ANRL Newsletter Archive/Active
3697
Kind::.pdf
ANRL Newsletter Archive/Inactive: /volume1/ANRL SYNC/ANRL Newsletter Archive/Inactive
3372
Kind::.pdf
ANRL Nudist Clubs & Organizations: /volume1/ANRL SYNC/ANRL Nudist Clubs & Organizations
2980
Kind::DIR
ANRL Nudist Organization Archive - Folders - Org names: /volume1/ANRL SYNC/ANRL Nudist Organization Archive
515
Kind::.mp4
ANRL Videos - .mp4: /volume1/ANRL SYNC/ANRL Videos: /volume1/ANRL SYNC/ANRL Videos
5
Kind::.mv4
ANRL Videos - .m4v: /volume1/ANRL SYNC/ANRL Videos: /volume1/ANRL SYNC/ANRL Videos
12
Kind::DIR
ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive
1
Kind::.pdf
ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive: /volume1/ANRL SYNC/ANRL Whos Who Archive
362
Kind::.mp4
Gary Nichols - Video Conversion - .mp4: /volume1/homes/Gary Nichols/Drive: /volume1/homes/Gary Nichols/Drive
106
Kind::.m4v
Gary Nichols - Video Conversion - .m4v: /volume1/homes/Gary Nichols/Drive: /volume1/homes/Gary Nichols/Drive
1
Kind::.mp3
Gary Nichols - Video Make .mp3 Nested - .mp3: /volume1/ANRL SYNC/ANRL Audio New
119
Kind::.mp3
Bob: ANRL Audio - rap .mp3: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Audio - rap/Audio-Adjusted
123
Kind::.mp3
Bob: ANRL Audio Tape MP3: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Audio - rap/Audio-Adjusted
0
Kind::.mp3
Bob: ANRL Board Meeting MP3: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Board Meeting MP3
14
Kind::.pdf
Bob: ANRL Board Meeting Notes: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Board Meeting Notes
45
Kind::.pdf
Bob: ANRL Cove Player Programs: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Cove Player Programs
26
Kind::.fmp12
Bob: ANRL Database Golden Conflicted Copies: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL Database Golden Conflicted Copies
6
Kind::.mp4
Bob: ANRL-Videos: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL-Videos
3
Kind::.pdf
Bob: Audio Transcripts of tapes by Evan Nix: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/Audio Transcripts of tapes by Evan Nix
1
Kind::.fmp12
Bob: FileMaker BU Archive: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/FileMaker BU Archive
20
Kind::.md
Source code for web pages: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/2TB-Passport/AANR-ANRL/NAS Sync 03/ANRL_PAGES
256
Kind::.jpg
JPG data from scanned Books: /volume1/homes//admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data Books
14664
Kind::.jpg
JPG data from Foreign Magazines: /volume1/homes//admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data Foreign Magazines
281778
Kind::.jpg
JPG data from US Magazines: /volume1/homes/admin/Drive/Backup/MacBook-Pro.local/Volumes/EMW 0517/ANRL Archives/JPG Data US Magazines
210835

NAS Stats CODE 3

This is the code for perl script nastable (the textexpander snippet)

#!/bin/bash
# Aub 18, 2020 rap
# this makes markdown table from NAS Stats
# /Users/rproctor/dropbox/make_table_NAS_Stats.pl %clipboard
/Users/rproctor/Dropbox/bin/NAS_Table_from_stats.pl %clipboard

NAS Stats CODE4

This is the perl code for nastable

 #!/usr/bin/perl

# /Users/rproctor/Dropbox/bin/NAS_Table_from_stats.pl

# Perl printf to use commas as thousands-separator
# https://stackoverflow.com/questions/33442240/perl-printf-to-use-commas-as-thousands-separator
# use v5.10.1;
# use Number::Format 'format_number';

# Updated Aug 25, 2015 with purchase of 141 shares
# updated for 7-for-1 split Jun 06, 2014

# this is for textedit and it's shortcut is "aastock"
# calculates gain/loss on Apple Stock deal
  $pasted = `pbpaste` ;
# printf "[%s]\n", $pasted;

# | Database | Browse Only | W/O Delete | All |
# |:-------------------- |:-------------------- |:-------------------- |:-------------------- |
  printf "NAS Stats\n\n";
  printf "| Name                                               | Kind | Count |\n";
  printf "|:--------------------------------------------------|:------|------:|\n";

  $kind = "other";
  @Fld = split('\n', $pasted, 999);
  for ($i = 0; $i <= $#Fld; $i++) {
# printf "Looking at record %s\n", $Fld[$i];
    if ($Fld[$i] =~ /^(Kind::)(.*)/) {
      $kind = $2;    }
    if ($Fld[$i] =~ /^\s*\#/) {
      if ($Fld[$i] =~ /(\d+-\d+-\d+)\s*/) {
        $date = $1;
      }
    }
    elsif ($Fld[$i] =~ /^(\d+)$/) {
      $count = $Fld[$i];
#     $thousand_count = format_number($Fld[$i]);
# A more perl-ish solution:
# 
# $a = 12345678;                 # no comment
# $b = reverse $a;               # $b = '87654321';
# @c = unpack("(A3)*", $b);      # $c = ('876', '543', '21');
# $d = join ',', @c;             # $d = '876,543,21';
# $e = reverse $d;               # $e = '12,345,678';
# print $e;
# outputs 12,345,678.
      $a = $count;                   # no comment
      $b = reverse $a;               # $b = '87654321';
      @c = unpack("(A3)*", $b);      # $c = ('876', '543', '21');
      $d = join ',', @c;             # $d = '876,543,21';
      $e = reverse $d;               # $e = '12,345,678';
      printf "| %s | %s | %s |\n", $folder, $kind, $e;
    }
    else {
      $folder = $Fld[$i];
    }
#   printf "%03d %s\n", $i, $Fld[$i];
  }
  printf "[NAS Stats on date: %s ]\n", $date;

# $out = ((40 * 7) + 141)  * $pasted;
# $in = (20 * 545) + (20 * 640) + (141 * 106.46) ;  # was 540 until Jul 02, 2014
# Aug 24, 2015 purchase 141 shares @ 106.46 
# $net = $out - $in;
# printf "In = %d\n", $in;
# printf "Out = %d\n", $out;
# printf "%s - My Apple is up \$%d", $pasted, $net if $net >= 0;
# printf "%s - My Apple is down \$%d", $pasted, -$net if $net < 0;
__END__

#!/bin/bash
# Dec 01, 2013 rap
# this swaps date from Dec 01, 2013 to 2013-12-01
/Users/rproctor/dropbox/bin/aapple.pl %clipboard

Dec 05, 2013 Thu 571 - My Apple is down $760