【发布时间】:2013-08-26 19:12:47
【问题描述】:
我创建了这个 bash 文件,并在其上放置了我经常运行的用于从我的数码相机同步文件的命令。关键是它什么都没有!我错过了什么?
谢谢!
代码:
#!/bin/bash
#temporal
mkdir /tmp/canon
#copy files from camera
rsync -r /run/user/mango/gvfs/g*/DCIM /tmp/canon
cd /tmp/canon
#get files from subdirs
find ./ -name '*.JPG' -exec mv '{}' ./ \;
#remove dirs
ls -l | awk -F'[0-9][0-9]:[0-9][0-9]' '/^d/{print $NF}'| xargs -i rm -rf '{}' \;
#recreate folder structure with year|month pattern
jhead -n%Y/%m/%f *.JPG
#Sync with external HD
rsync -r --ignore-existing . /media/mango/WD/FOTOS/
【问题讨论】:
-
你有什么错误吗?
-
尝试将
-v添加到 rsync 中,看看它是否有作用。之后检查其他命令。还要确保您的文件名以.JPG结尾,而不是.jpg。您可以使用-iname忽略大小写。 -
您需要使其可执行吗?即“chmod u+x script.sh”
-
不解析 ls 输出。改用这个
for curFile in *; do [[ -d "$curFile" ]] && [[ curFile =~ ^[0-9][0-9]:[0-9][0-9]$ ]] && rm -rf "$curFile"; done -
感谢您提供的所有提示,让它变得冗长只是向我展示了错误。谢谢!
标签: linux bash unix terminal sh