【发布时间】:2020-05-02 09:21:12
【问题描述】:
所以我使用一个脚本,根据那里的文件名将特定文件复制到特定文件夹。我想扩展脚本,以便在复制进度后删除文件名中的一部分。这是一个示例文件名看起来像这个 Image_000058_19_12_2019_1920x1080.jpg 我喜欢从中删除分辨率(_1920x1080)部分。有没有办法将它添加到我的脚本中(见下文)感谢@fedxc 的脚本。
cd "$HOME/Downloads"
# for filename in *; do
find . -type f | while IFS= read filename; do # Look for files in all ~/Download sub-dirs
case "${filename,,*}" in # this syntax emits the value in lowercase: ${var,,*} (bash version 4)
*.part) : ;; # Excludes *.part files from being moved
move.sh) : ;;
# *test*) mv "$filename" "$HOME/TVshows/Glee/" ;; # Using move there is no need to {&& rm "$filename"}
*test*) scp "$filename" "imac@imac.local:/users/imac/Desktop/" && rm "$filename" ;;
*american*dad*) scp "$filename" "imac@imac.local:/users/imac/Movies/Series/American\ Dad/" && rm "$filename" ;;
*) echo "Don't know where to put $filename" ;;
esac
done```
【问题讨论】: