我获得了大量代码,用于从目录及其子文件夹中搜索和复制 csv 中列出的文件一个答案对于我之前的问题。
但是,某些文件不会被复制。我使用的代码是:
while IFS=, read -r file rest
do
find "$sourcefolder" -name "$file" -exec cp -i '{}' "$destfolder" \;
[[ -e "$destfolder/$file" ]] || badfiles=$(printf "%s\n%s" "$file" "$badfiles")
done < "$csv"
if [[ -z "$badfiles" ]]; then
echo -e "\e[32mAll files were succesfuly copied."
echo -e "\e[0m"
exit
else
echo -e "\e[31m"
printf 'Some files were not copied, please see below list:\n%s\n'
echo -e "\e[34m"
printf "$badfiles"
fi
echo -e "\e[0m \n\n"
exit
由于某种原因,列出的 5 个文件未找到并被跳过。该脚本不知何故错过了它们,并且没有在错误报告中报告它们。我知道错误日志记录有效,因为如果我创建一个不存在的完全随机的文件名并将其包含在 csv 中,脚本会将其报告为未复制。但 csv 中的这些特定条目似乎存在一些问题。文件或目录的权限没有问题。
5个问题文件的输出ls -l
如下所示:
-rwxrwxrwx 1 archive archive 29067850 Mar 8 2008 bap_02_08_0184_01_tomorrow's_world.mp4
-rwxrwxrwx 1 archive archive 148025274 May 21 2010 ./Ascent_Media_MP4files/MP4 FILES/OralHistory_HistoryOFScience_Walter.mp4
-rwxrwxrwx 1 archive archive 57990878 Nov 29 2008 ./Flash_Files/Tomorrows World_TX_01_04_1976_LSF1056Y.mp4
-rwxrwxrwx 1 archive archive 203758186 Jul 17 2009 ./Ascent_Media_MP4files/MP4 FILES/not so much a programme more a way of life - LCA6710B - 29_01_1965.mp4
-rwxrwxrwx 1 archive archive 179529394 May 25 2010 ./Ascent_Media_MP4files/MP4 FILES/SundayNight_WHAuden_LMA6900T_TX28_11_1965.mp4
csv 文件及其上方和下方的违规条目是:
Tomorrows World_TX_18_09_68_TX_11_12_68_LSF5910A_LSF5911T.mp4,KA0004107-001.mp4
TomorrowsWorld_LSF5910A_LSF5911T_18_09_1968_11_12_1968.mp4,KA0004107-002.mp4
bap_02_08_0184_01_tomorrow's_world.mp4,KA0004117-002.mp4
bap_02_08_0184_02_tomorrow's_world.mp4,KA0004117-003.mp4
Tomorrows World_TX_07_05_1969_LSF5931B.mp4,KA0004117-001.mp4
bap_02_08_0863_tomorrow's_world.mp4,KA0004118-002.mp4
Billy Bunter_TX_09_09_1956_LCH9311A.mp4,HPR000185-001.mp4
ZooQuestToGuiana_6_LGF6998A_18_10_1955.mp4,HPR000211-001.mp4
OralHistory_HistoryOFScience_Walter.mp4,HPR000214-001.mp4
ORalHistory_HistoryOfScience_NevillMott.mp4,HPR000215-001.mp4
OralHistory_HistoryOfScience_FredSanger.mp4,HPR000216-001.mp4
Tomorrows World_TX_04_01_1967_LSF5856D.mp4,KA0003210-001.mp4
Tomorrows World_TX_16_10_1975_and_23_10_1975_LSF6428R.mp4,KA0003211-001.mp4
Tomorrows World_TX_01_04_1976_LSF1056Y.mp4,KA0003213-001.mp4
Panorama_TX_20_11_1962_LCA6829R.mp4,KA0003214-001.mp4
Nationwide_TX_ 06_10_1970_ LCA3040B.mp4,KA0003215-001.mp4
Preservation Stockshots_LN1221-LN1288.mp4,KA0004516-001.mp4
Whickers_World_Quest_For_Beauty_TX_22_10_1966_LCA8262X.mp4,KA0004556-001.mp4
not so much a programme more a way of life - LCA6710B - 29_01_1965.mp4,KA0004587-001.mp4
Further_Adventures_Of_The_Musketers_1_Defiance_TX_21_05_1967_LDL5239W.mp4,KA0004592-001.mp4
pioneers of social change - 10 to sum up - ESB6385P - 26_11_1962.mp4,KA0004625-001.mp4
Its Magic - TX 29_11_1957 - LLV5261E.mpg,KA0004351-001.mp4
2MOROSWORLD_LSF1015P_06_03_1975.mp4,KA0003171-001.mp4
Tomorrows World - LSF1072E - 27_05_1976.mp4,KA0003196-001.mp4
ManAlive_LivingInSin_LGF5720B_02_03_1966.mp4,HPR000153-001.mp4
SundayNight_WHAuden_LMA6900T_TX28_11_1965.mp4,KA0005555-001.mp4