I have created one as shown below:-
Code: Select all
###/home/pi/CCTV/RearOfHouse/ARC2019042134139.jpg = full path inc filename
##create an array with all the .jpg files found inside ~/CCTV/RearOfHouse/
#!/bin/bash
arr=(~/CCTV/RearOfHouse/*.jpg)
# iterate through array using a counter
for ((i=0; i<${#arr[@]}; i++)); do
#do something to each element of array
j=${arr[$i]:9:26} ### this sets "j" to equal "CCTV/RearOfHouse/ARC201904"
echo "${j}" ##just to check I am right
### mkdir -p "${j}"
echo "${arr[$i]:29:6}" #gives the year and month
# echo "${arr[$i]}" #gives the full path including filename
# echo "${arr[$i]:0:5}" #gives the output '/home'
done
mkdir -p "${j}" ### but this creates Dirs in location of this exec file (/home/pi/ExecFiles)?
e.g. so the result would be creating different directories such as "/CCTV/RearOfHouse/201904", or "/CCTV/RearOfHouse/201905"
I can then use further code to move files into their relevant directories, perhaps within the same 'for' loops.
Thanks
WD