[arm-allstar] How difficult would it be to maybe add this feature to a future update to the audio archive feature?

Neil Mooney neilmooney at live.co.uk
Sat Jan 6 11:35:03 EST 2018


I wrote a bash script to do this and it works well for me. I like writing things in a simple easy to follow way so others can change it if they want to. I run it as a menu item but you could automate it. Just change the paths where it tells you to match what you need.




#!/bin/bash
#
# Neil Mooney M0NFI
# May 2017
#
# Script to move Asterisk recordings from default directory to an archive directory
# Directory are created based on the recording file date
# Directory structure is based on SavePath variable set below and will look like
# SavePath / year/ month / day / files
#
# The script moves all recordings except from the current day is variable NotToday is set to 1
#
#
#



RecordingPath="/media/usb/recordings/45560" # set the directory where your recodring are here
SavePath="/media/usb/recordings/archive/45560" # set where you want you files to be moved to
NotToday=1 # set to 1 if you don't want to move todays files or 0 if you want to move all files


FileName="" # Variables used to store file info while processing
FileYear=""
FileMonth=""
FileDay=""
FileNew=""
FileDate=""
TodayDate=$(date +%Y%m%d)


for entry in "$RecordingPath"/*.*
do


    FileName=${entry##*/}

    FileYear=${FileName:0:4}
    FileMonth=${FileName:4:2}
    FileDay=${FileName:6:2}
    FileDate="$FileYear$FileMonth$FileDay"
    FileNew="$SavePath/$FileYear/$FileMonth/$FileDay/"


    if [ $TodayDate != $FileDate ] || [ $NotToday == "0" ]
    then

        if [[ ! -d $FileNew ]]
        then

    echo "Directory $FileNew does not exist"

            mkdir --parents $FileNew

            echo "Made directory $FileNew"
        fi

        mv $entry $FileNew
echo "Moved file - $entry"

    fi


done




Regards,

Neil
M0NFI
________________________________
From: arm-allstar <arm-allstar-bounces at hamvoip.org> on behalf of "Terry Bethlehem via arm-allstar" <arm-allstar at hamvoip.org>
Sent: 06 January 2018 03:52:42
To: ARM Allstar
Cc: Terry Bethlehem
Subject: Re: [arm-allstar] How difficult would it be to maybe add this feature to a future update to the audio archive feature?

This looks a bit over my skill level at the moment. I'll have to look at a
beginner's scripting book to have it show me what's going on instead of
blindly copying code. I could practice on my linux laptop I guess for now,
until I can begin to understand it better.

On Jan 5, 2018 10:36 PM, Doug Crompton via arm-allstar <
arm-allstar at hamvoip.org> wrote:

> Terry,
>
>  I did some testing of my hypothesis that I sent earlier and it needed some
> massaging. This works -
>
> rsync -Ravm --remove-source-files --include=`date -d "yesterday"
> +%Y%m%d*.wav` --exclude '*' . `date -d "yesterday" +node-archive-%Y%m%d`
>
> So if you had the files -
>
> 20180104_1.wav  20180104_2.txt  20180104_2.wav
>
> In the directory this was run in it would create the directory
>
> node-archive-20180105
>
> with the contents -
>
> ls node-archive-20180105/
>
> 20180105_1.wav  20180105_2.wav
>
> This assumes the current date is 20180106. It further assumes the files you
> are archiving have the date first then some text with a .wav extent. This
> can be changed in the rsync line if necessary as can the name of the
> archive directory.  This example removes the source files after copying to
> the destination directory. If you want to keep them remove the
> --remove-source-files directive.
>
> I suggest you create a test directory populate it with some file that have
> the names and correct dates of the files you want to archive and test run
> this. You can create dummy files like this:
>
> cd /
> mkdir test
> cd test
> >20180105_test.wav
> >20180105_test2.wav
> etc.
>
> Remember the date has to be yesterday. Then run the rsync line. It should
> create the archive in the same directory and delete the source files you
> created.
>
> Once you get this working you could run it with a cron job daily to archive
> yesterdays files.
>
> Again if you need help with this let me know.
>
>
> *73 Doug*
>
> *WA3DSP*
>
> *http://www.crompton.com/hamradio <http://www.crompton.com/hamradio>*
>
>
>
>
> On Fri, Jan 5, 2018 at 3:35 AM, "Terry Bethlehem via arm-allstar" <
> arm-allstar at hamvoip.org> wrote:
>
> > For me, I'd like a feature that creates a folder, on your external drive,
> > each day, with its contents. Say for example, at midnight, the pi
> creates a
> > folder named 20180105, and dumps all the audio files in it. When the next
> > day comes, it creates a new folder then dumps the files in the new
> folder.
> > I don't know how many people that actually use this feature, would really
> > like this or don't care. I archive all the files, to my pc, when my node
> is
> > offline for the day. I create folders with the date. I scroll through
> > thousands of files, for a single day, to move them to the appropriate
> date
> > folder I created on my pc. Automating this would be awesome for me. I
> don't
> > know how many agree with my suggestion. I also know you guys have other
> > things you're trying to improve and implement.
> >
> > Any input is appreciated. I'm just wishing for a little bit of automated
> > housekeeping, instead of plowing through thousands of wav files, trying
> to
> > find what I'm looking for. I'm not a scripter yet.
> > _______________________________________________
> >
> > arm-allstar mailing list
> > arm-allstar at hamvoip.org
> > http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
> >
> > Visit the BBB and RPi2/3 web page - http://hamvoip.org
> >
> _______________________________________________
>
> arm-allstar mailing list
> arm-allstar at hamvoip.org
> http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
>
> Visit the BBB and RPi2/3 web page - http://hamvoip.org
>
_______________________________________________

arm-allstar mailing list
arm-allstar at hamvoip.org
http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar

Visit the BBB and RPi2/3 web page - http://hamvoip.org


More information about the arm-allstar mailing list