2014-10-29 4 views
0

에 여러 개의 파일을 추가하는이 쉘 스크립트는 폴더에있는 모든 것을 전송에 추가해야합니다. 하나의 폴더로 잘 동작하지만, 같은 폴더에 두 개 이상의 폴더를 추가하면 두 번째 폴더는 무시됩니다.inotifywait

while true; 
do 
file=$(inotifywait -e moved_to --format %f /srv/watchfolderfilme) 
file="/srv/watchfolderfilme/$file" 
    transmission-create -o $file.torrent -s 16384 -t http://0.0.0.0:6969/announce $file 
    mv $file /srv/downloads 
    chmod 0777 $file.torrent 
    cp $file.torrent /srv/newtorrentfiles 
    mv $file.torrent /srv/watchfoldertorrents 
done 

답변

0
내 솔루션 Rethough

여러 잘 동작 더 나은 하나

inotifywait -m /srv/watchfolderfilme -e create -e moved_to | 
    while read path action file; do 
# echo "The file '$file' appeared in directory '$path' via '$action'" 
    chmod 0777 $path$file 
    transmission-create -o /srv/newtorrentfiles/$file.torrent -s 16384 -t http://0.0.0.0:6969/announce $path$file 
    mv $path$file /srv/downloads 
    chmod 0777 /srv/newtorrentfiles/$file.torrent 
    cp /srv/newtorrentfiles/$file.torrent /srv/watchfoldertorrents 
done 
를 추가 발견