Apologies to all, I think I've got it all wrong!
I thought that by connecting my external HDD (as per I have done with mountpoint /pi/mnt/CamFiles), I could then FTP files straight from my CCTV Cameras into that directory, do some changes to them, and they would be automatically moved onto my HDD. I created a symlink to be able to connect to (ln -s mnt/Camfiles ~CamFiles) from my login position, but it seems I somehow cannot move the files onto my HDD.
The cameras will FTP the files into that directory and I have done lots of searching on 'automatically moving files from a raspberry pi onto a USD HDD' and all I've found is information on creating mountpoints (which I've done in fstab) and dragging/dropping any files into that directory using either a mac or windows connection (mine is windows 10) through windows explorer.
All it seems I am doing is creating new directories based upon the file dates coming in, and then moving the files into them.
My pi is now full and if I run this command "sudo du -xh / | grep -P "G\t"" (found through my seraches) to find out by what, I get:-
Code: Select all
sudo du -xh / | grep -P "G\t"
4.2G /home/pi/mnt/CamFiles/RearOfHouse/mp4Files/201910_mp4
4.2G /home/pi/mnt/CamFiles/RearOfHouse/mp4Files
4.5G /home/pi/mnt/CamFiles/RearOfHouse
2.2G /home/pi/mnt/CamFiles/Dots/2019/10/01
3.3G /home/pi/mnt/CamFiles/Dots/2019/10
3.3G /home/pi/mnt/CamFiles/Dots/2019
3.3G /home/pi/mnt/CamFiles/Dots
13G /home/pi/mnt/CamFiles/FrontOfHouse/mp4Files/201910_mp4
13G /home/pi/mnt/CamFiles/FrontOfHouse/mp4Files
14G /home/pi/mnt/CamFiles/FrontOfHouse
21G /home/pi/mnt/CamFiles
21G /home/pi/mnt
21G /home/pi
21G /home
2.1G /usr/lib
1.1G /usr/share
3.3G /usr
25G /
So it seems to me the files are just building up inside 'pi/mnt/CamFiles' which my script (below) works on the files.
Code: Select all
#!/bin/bash
#source $HOME/.bash_profile
## this file is being ran from the directory on the HDD '/CamFiles/FrontOfHouse/'
# create an array with all the files/dir inside ~/CamFiles/FrontOfHouse/
####!/bin/bash
arr=(/home/pi/mnt/CamFiles/FrontOfHouse/*.jpg)
# iterate through array using a counter
for ((i=0; i<${#arr[@]}; i++)); do
################### SET UP VARIABLES FOR CODE ###########################
j=${arr[$i]:38:6}"_jpg" ## 201903_jpg
echo "j= " ${j}
k=${arr[$i]:0:34}"/jpgFiles/" ## /home/pi/mnt/CamFiles/FrontOfHouse/jpgFiles/
echo "k= " ${k}
h=${arr[$i]:0:56} ## /home/pi/mnt/CamFiles/FrontOfHouse/ARC20190315080521.jpg
echo "h= " ${l}
m=${arr[$i]:0:56} ##/home/pi/mnt/CamFiles/FrontOfHouse/ARC20190315080521.jpg
echo "m- " ${m}
n=${k}${j} ## /home/pi/mnt/CamFiles/FrontOfHouse/201903
echo "n= "${n}
o=${arr[$i]:38:6} ## 201903
echo "o= " ${o}
oo="${k}${o}""_jpg"
echo "oo= " ${oo}
l="${k}${j}"
echo "l= " ${l}
################### CREATE ANY NEW DIRECTORIES THAT NEED CREATING ##############
mkdir -p "${oo}" ### this creates new directories in location of this exec file
echo " DIR " "${oo}" " Built"
################# MOVE ALL FILES TO RELEVANT DIRECTORIES NEXT ##################
### mv pathtofileA pathtofileB ###
aa="201901_jpg"
bb="201902_jpg"
cc="201903_jpg"
dd="201904_jpg"
ee="201905_jpg"
ff="201906_jpg"
gg="201907_jpg"
hh="201908_jpg"
ii="201909_jpg"
jj="201910_jpg"
kk="201911_jpg"
ll="201912_jpg"
echo "Starting to move files.........."
if [ ${j} = ${aa} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${bb} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
# if [ ${j} = ${cc} ]; then
#fi
if [ ${j} = ${cc} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${dd} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${ee} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${ff} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${gg} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${hh} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${ii} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
if [ ${j} = ${jj} ]; then
echo "moving " "${m}" " to " "${l}"
mv "${m}" "${l}"
fi
echo "All files moved."
done
I thought I could avoid buying a ready built CCTV monitoring system as this was by far the cheaper option, but it is looking more likely I will have to now.
I am going to give it a little more time searching, but am not holding my breath, as it looks to me the pi cannot automatically move files to my HDD.
Thanks
WD
(I'm going to add 'rm -rf RearOfHose' and all the other subdirectories to the end of my scripts to see what that does)