/
hubbitus
/
shell.scripts
Обзор
Документация
Войти
/
hubbitus
/
shell.scripts
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
seen
22 строки
719 B
Pavel Alexeev
Add 'seen' command which was before function. Handle directories and files of videos to mark it seen
09 сен 2017, 15:58
09 сен 2017, 15:58
09a7e56
Код
Авторство
О чём код?
#!/bin/bash # Small helper script to mark video as seen # If it called on file then it will be truncated to 0 size and added suffix .seen # If It called on directory we try truncate so-named file in it and rename directory with .seen suffix also : ${1?"You must provide argument: `basename $0` target-video-file1 [file1, file2, file3]"} SUFFIX=.seen set -x for f in "$@"; do # Don't touch & remove but mv instead to do not lose extended attributes! mv "$f" "${f}${SUFFIX}" if [ -d "$f${SUFFIX}" ]; then find "$f${SUFFIX}" -regextype awk -regex "${f}${SUFFIX}/${f}\.(webm|ogg|avi|mpeg|mp4)" -exec sh -c ': > "{}"' \; mkdir "${f}${SUFFIX}/#shots" else # just empty it : > "${f}${SUFFIX}" fi done