Answer the question
In order to leave comments, you need to log in
Where is the script error?
Hello. Please help me find a bug in the script:
The task of the script is to find a match between the files in the Downloads folder and in the folder of a specific series, then move all the files from Downloads to the correct folder. Nothing global.
So, the bug is that if there are 2 updates of the series at the same time matching the conditions, then the script from Downloads drags all the files (of the desired and unnecessary series) into the first corresponding folder of the series.
#!/bin/bash
#ищем файлы с расширением .mkv, .m4v
Downloads_file=$(find /volume1/Geroev_Avenue_18/Downloads/ -type f \( -iname "*.mkv" -or -iname "*.m4v" -or -iname "*.mp4" -or -iname "*.ts" -or -iname "*.avi" \) -and -mmin +15 -exec basename "{}" ';' | shuf -n 1 | sed -n '1p' );
echo $Downloads_file
if [ -n "$Downloads_file" ]; then
#ищем местоположение в загрузках
Downloads_folder=$(find /volume1/Geroev_Avenue_18/Downloads/ -type f \( -iname "*.mkv" -or -iname "*.m4v" -or -iname "*.ts" -or -iname "*.avi" \) -and -mmin +15 -exec dirname "{}" ';' | sed -n '1p' );
fi
echo $Downloads_folder
#проверяем в сериалах файлы с расширением .mkv, .m4v,соответствующего названия
if [ -n "$Downloads_file" ]; then
Serials_file=$(find /volume1/Geroev_Avenue_18/Shared_Videos/Serials/ -type f -iname "$Downloads_file" -exec basename "{}" ';' | sed -n '1p' );
fi
echo $Serials_file
#Media Renaimer
#Folder
if [ -n "$Downloads_folder" ]; then
# sed-ом заменяем символы кирилицы на символы латиницы
TRS=` echo $Downloads_folder | tr [:blank:] "_"`
mv -v "$Downloads_folder" "$TRS"
fi
#File
if [ -n "$Downloads_folder" ]; then
# sed-ом заменяем символы кирилицы на символы латиницы
TRS=` echo $Downloads_file | tr [:blank:] "_"`
mv -v "$Downloads_folder""/""$Downloads_file" "$Downloads_folder""/""$TRS"
fi
#ищем местоположение в сериалах
if [ -n "$Serials_file" ]; then
Serials_folder=$(find /volume1/Geroev_Avenue_18/Shared_Videos/Serials/ -type f -iname "$Downloads_file" -and -mmin +15 -exec dirname "{}" ';')
fi
echo $Serials_folder
Answer the question
In order to leave comments, you need to log in
you can replace part of the code with this
find /volume1/Geroev_Avenue_18/Downloads/ -type f -regex ".*\.\(mkv\|m4v\|ts\|avi\)"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question