-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtimestamp_parallel.sh
executable file
·80 lines (67 loc) · 2.17 KB
/
timestamp_parallel.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
intput_format=".JPG"
output_format=".png"
photo="*${intput_format}"
indir="./photo_in/"
outdir="./photo_timestamp/"
files=$indir$photo
start_time=$SECONDS
files_count=$(ls ${indir} -Uba1 | grep ${intput_format} | wc -l)
################################################################
################################################################
# Setting FONT
FONT_INSTALLED=$(fc-list | grep -i "roboto");
if [ -z "$FONT_INSTALLED" ]; then
echo "The Roboto font is not currently installed.";
FONT_INSTALLED=$(fc-list | grep -i "ubuntu");
if [ -z "$FONT_INSTALLED" ]; then
echo "The Ubuntu font is not currently installed.";
font="Arial"
echo "Using the Arial font.";
else
font="Ubuntu";
echo "Using the Ubuntu font.";
fi
else
font="Roboto";
echo "Using the Roboto font.";
fi
################################################################
################################################################
#Check if input dir exists, else quit.
DIR="${indir}"
if [ -d "$DIR" ]; then
echo "'$DIR' found as input dir, please wait ..."
else
echo "Error: '$DIR' NOT found. Exit script.";
exit 1;
fi
#Check if output dir exists, else create.
DIR="${outdir}"
if [ -d "$DIR" ]; then
echo "'$DIR' found as output dir, please wait ..."
else
echo "Warning: '$DIR' NOT found as output dir. Creating output dir.";
mkdir "$DIR";
fi
# check if files are there in input dir
if (( ${files_count} < 1 )); then
echo "Error: No files [${files_count}] found in [${files}]."
exit 1;
fi
################################################################
################################################################
echo "Adding timestamp to all [${files_count}] the images.";
find "${indir}" -name "*${intput_format}" | \
parallel --bar --progress --eta -I% \
--max-args 1 \
"./timestamp_file.sh" % \
"${font}" \
"${outdir}" \
"${output_format}";
printf '\nAdding timestamp is finished!\n'
run_time=$(($SECONDS - $start_time))
echo "This took $((${run_time} / 60)) minutes and $((${run_time} % 60)) seconds."
# LICENSE
## CC BY-SA 4.0
## https://github.com/edzob/photo_scale_timestamp_script