aboutsummaryrefslogtreecommitdiff
path: root/shell/ftag-add-dir-rec.sh
blob: c5a1f6be8d566cb3af2ac3e676e63d0cb834abfa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/sh

if [ $# -eq 0 ]
then
    echo "Usage: $0 DIR..."
fi

tmp_file_0="$(mktemp)"
> "$tmp_file_0"
for dir in "$@"
do
    find "$dir" -type f -exec sh -c "printf '%s\t%s\n' \"$(basename {})\" \"{}\" >> \"$tmp_file_0\"" ';'
done

# cut -f1 < "$tmp_file_0"

for file in $(cut -f1 < "$tmp_file_0" | uniq -u)
do
    echo "$file"
done

# uniq -u < "$tmp_file_0" | xargs -d '\\n' ftag file add
rm "$tmp_file_0"