Added test and test description to check_folder_for_extension function.
11
README.md
@@ -1,2 +1,13 @@
|
|||||||
Collection of useful bash functions.
|
Collection of useful bash functions.
|
||||||
|
|
||||||
|
Every script file includes the function and a test to show how it's meant to be used and check that the function really works. Just executing the script runs that test.
|
||||||
|
|
||||||
|
## Check folder for extension
|
||||||
|
|
||||||
|
Checks a given folder for certain file extensions recursively. The [check_folder_for_extension test folder](cffe_test) contains of 13 files, 12 of them images, which should be found by the test.
|
||||||
|
|
||||||
|
function call:
|
||||||
|
```
|
||||||
|
check_folder_for_extension ./cffe_test "*.jpg *.JPG"
|
||||||
|
```
|
||||||
|
For multiple extensions (or other parts of the file name to match) space separate the list, like shown above.
|
||||||
BIN
cffe_test/16_kochen10_.jpg
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
cffe_test/16_kochen11_.jpg
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
cffe_test/16_kochen12_.jpg
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
cffe_test/16_kochen1_.jpg
Normal file
|
After Width: | Height: | Size: 129 KiB |
BIN
cffe_test/16_kochen2_.jpg
Normal file
|
After Width: | Height: | Size: 142 KiB |
BIN
cffe_test/16_kochen3_.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
cffe_test/16_kochen4_.jpg
Normal file
|
After Width: | Height: | Size: 140 KiB |
BIN
cffe_test/16_kochen5_.jpg
Normal file
|
After Width: | Height: | Size: 148 KiB |
BIN
cffe_test/16_kochen6_.jpg
Normal file
|
After Width: | Height: | Size: 141 KiB |
BIN
cffe_test/16_kochen7_.jpg
Normal file
|
After Width: | Height: | Size: 147 KiB |
BIN
cffe_test/16_kochen8_.jpg
Normal file
|
After Width: | Height: | Size: 145 KiB |
BIN
cffe_test/16_kochen9_.jpg
Normal file
|
After Width: | Height: | Size: 150 KiB |
0
cffe_test/nonimage1.txt
Normal file
@@ -37,8 +37,8 @@ __check_folder() {
|
|||||||
|
|
||||||
|
|
||||||
__test() {
|
__test() {
|
||||||
MYFOLDER="./test";
|
MYFOLDER="./cffe_test";
|
||||||
__check_folder $MYFOLDER "*.jpg *.JPG *.mp4 *.MP4"
|
__check_folder $MYFOLDER "*.jpg *.JPG" # space separated list for multiple extensions!
|
||||||
FILE_COUNT=$?
|
FILE_COUNT=$?
|
||||||
echo "Found $FILE_COUNT files in folder $MYFOLDER, length of files array is ${#FILESNPATHS[*]}.";
|
echo "Found $FILE_COUNT files in folder $MYFOLDER, length of files array is ${#FILESNPATHS[*]}.";
|
||||||
for ((FILE_C=0;FILE_C<${#FILESNPATHS[*]};FILE_C++)); do
|
for ((FILE_C=0;FILE_C<${#FILESNPATHS[*]};FILE_C++)); do
|
||||||
|
|||||||