[英]Wait google chrome all downloads finshed with shell command
Every day I need to download a lot of pictures in a row through the Google plugin, concentrated in a few minutes.每天我需要通过谷歌插件连续下载很多图片,集中在几分钟。 So I want to have a script that can clearly let me know that the download tasks currently in progress by Google have all been completed, so that I can easily go to the next processing flow.
所以我想有一个脚本可以清楚的让我知道Google目前正在进行的下载任务已经全部完成,这样我就可以很方便的进行下一个处理流程了。
My main reference materials are:我的主要参考资料是:
1. Keyboard Maestro with lsof command 1. 使用 lsof 命令的键盘大师
2.shell command with stat 2.shell命令带stat
According to the first scenario, I have used the command根据第一种情况,我使用了命令
lsof -c /Chrome/i | grep "/Users/ifxl/Downloads/tmp_images/ref"
lsof -c /Chrome/i | grep "/Users/ifxl/Downloads/"
However, this judgment is very unstable, and it is often judged too early that the download has been completed, but in fact it is not.但是,这个判断很不稳定,经常过早的判断下载已经完成,但实际上并没有。
#! /bin/bash
export LANG="en_US.UTF-8"
PATH=/usr/local/bin:$PATH
dir="/Users/ifxl/Downloads/tmp_images/ref/"
# check whether $dir exists
#test -d "${dir}" || exit 1
last=0
current=1
while [ "$last" != "$current" ]; do
last=$current
current=$(find "${dir}" -exec stat -c "%Y" \{\} \; |
sort -n | tail -1)
sleep 10
done
echo "directory is now stable..."
This method will pop up an error reminder:该方法会弹出错误提示:
stat: illegal option -- c
usage: stat [-FLnq] [-f format | -l | -r | -s | -x] [-t timefmt] [file ...]
Is there a very elegant way to determine that all downloads have been completed in Google Chrome.是否有一种非常优雅的方法可以确定所有下载都已在 Google Chrome 中完成。
Or, is there a very ingenious way to achieve a very accurate judgment?或者,有没有一种非常巧妙的方法可以达到非常准确的判断?
You can write a browser extension that monitors downloads and communicate with it via web socket.您可以编写一个浏览器扩展来监控下载并通过 web 套接字与其通信。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.