![](/img/trans.png)
[英]Recursively appending names of all files in a directory with exif specific png meta data field (aesthetic_score) with linux / EXIFtool
[英]How to copy all files Norway.png in the same directory recursively with the name Bouvet-Island.png in Linux
我有一個帶有標志(/ flags)的目錄,在多個目錄中有文件名Norway.png。 由於不存在Bouvet Island標志,因此該國家(島)的挪威是等效的,僅需將所有Norway.png文件復制到名稱為Bouvet-Island.png的目錄中。
(以下是標志: https : //downloads.gosquared.com/pixels/flags.zip )
考慮每個Norway.png位於不同的目錄中,並且具有不同的大小。
我試過這樣的事情:
#!/bin/bash
echo "Renaming..."
# shell-expansion to loop specified files
for file in /var/www/images/flags/*/Norway.png; do
cp "$file" "Bouvet-Island.png";
done;
但是我收到以下消息:
cp: target ‘./flags/shiny/16/Norway.png’ is not a directory
cp: target ‘./flags/shiny/48/Norway.png’ is not a directory
cp: target ‘./flags/shiny/24/Norway.png’ is not a directory
cp: target ‘./flags/shiny/32/Norway.png’ is not a directory
cp: target ‘./flags/shiny/64/Norway.png’ is not a directory
cp: target ‘./flags/flat/16/Norway.png’ is not a directory
cp: target ‘./flags/flat/48/Norway.png’ is not a directory
cp: target ‘./flags/flat/24/Norway.png’ is not a directory
cp: target ‘./flags/flat/32/Norway.png’ is not a directory
cp: target ‘./flags/flat/64/Norway.png’ is not a directory
將find
與-exec
選項一起使用:
find /var/www/images/flags -name Norway.png \
-exec sh -c 'cp {} $(dirname {})/Bouvet-Island.png' \;
可能不是所有目錄中都包含Norway.png。 您可以在/var/www/images/flags/*/Norway.png中為文件添加以下檢查。 如果if(-f $ file)cp“ $ file”“ Bouvet-Island.png”; 完成
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.