Good evening,
I want to write a bash script that loops over all the files in a directory and if a file matches a regular expression, it outputs the filename and some additional info [using cat] to a txt file.
The script will be used to label an imageset to later create an LMDB to use in caffe.
Here is my attempt;
#!/bin/bash
for f in /absolutepath/train/*
do
if [$f == '/absolutepath/train/felix.*']
then $f cat ' 0' > train.txt
elif [$f == '/absolutepath/train/jonas.*']
then $f cat ' 1' > train.txt
elif [$f == '/absolutepath/train/joachim.*']
then $f cat ' 2' > train.txt
elif [$f == '/absolutepath/train/vriendinjoachim.*']
then $f cat ' 3' > train.txt
else $f cat ' 4' > train.txt
fi
echo "Done :D"
done
the files in the directory look like this: felix (1).jpg, felix (2).jpg,.....
If you know of an existing script that can do this for me don't hesitate to mention that too.
PS: this is only my second post so don't be harsh :)