簡體   English   中英

使用Linux腳本根據文件名模式查找和移動文件

[英]find and move files based on file name pattern using linux script

我想將兩個不同的文件名模式分類到兩個不同的文件夾中。

兩種文件名模式是:

  • 名稱包含:s00或e00或s00e00或s0e000或0x00-其中0 =數字[0-9]

  • 名稱包含有效的4位數字的年份
  • 名稱不包含:s00或e00或s00e00或s0e000或0x00-其中0 =數字[0-9]

這會將第一組移動到folder1:

mv *s[0-9][0-9]* *e[0-9][0-9]* *s[0-9]e[0-9][0-9][0-9]* *[0-9]x[0-9][0-9]* folder1

在這些文件不被占用的情況下,這會將具有有效年份的文件移動到folder2:

mv *19[0-9][0-9]* *20[0-9][0-9]* folder2

在這里,我假設“有效年”將在1900年至2099年之間。

感謝John1024。

這是用於識別和分離電影和電視節目的腳本。 只需確保在第一行的末尾編輯/ path / to / tv-shows /目錄,並在第二行的末尾編輯/ path / to / movies /目錄。

find "$TR_TORRENT_DIR/$TR_TORRENT_NAME" -type f -a -not -size -100M -a -not -size +2G -a -not -iname "*sample*" -a -iname "*s[0-9]*" -o -type f -a -not -size -100M -a -not -size +2G -a -not -iname "*sample*" -a -iname "*e[0-9]*" -o -type f -a -not -size -100M -a -not -size +2G -a -not -iname "*sample*" -a -iname "*s[0-9]e[0-9]*" -o -type f -a -not -size -100M -a -not -size +2G -a -not -iname "*sample*" -a -iname "*s[0-9]e[0-9][0-9][0-9]*" -o -type f -a -not -size -100M -a -not -size +2G -a -not -iname "*sample*" -a -iname "*[0-9]x[0-9][0-9]*" -exec cp {} /path/to/tv-shows/ \;

find "$TR_TORRENT_DIR/$TR_TORRENT_NAME" -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*s[0-9]*" -a -iname "*19[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*e[0-9]*" -a -iname "*19[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*s[0-9]e[0-9]*" -a -iname "*19[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*s[0-9]e[0-9][0-9][0-9]*" -a -iname "*19[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*[0-9]x[0-9][0-9]*" -a -iname "*19[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*s[0-9]*" -a -iname "*20[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*e[0-9]*" -a -iname "*20[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*s[0-9]e[0-9]*" -a -iname "*20[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*s[0-9]e[0-9][0-9][0-9]*" -a -iname "*20[0-9][0-9]*" -o -type f -a -size +500M -a -not -iname "*sample*" -a -not -iname "*[0-9]x[0-9][0-9]*" -a -iname "*20[0-9][0-9]*" -exec cp {} /path/to/movies/ \;

然后,您可以將其添加到腳本的底部,該腳本將刪除和刪除完成播種的種子。 您將需要在兩個位置都替換用戶名和密碼。

transmission-remote --auth=username:password -l | grep Finished | \
awk '{print $1}' | xargs -n 1 -I % transmission-remote --auth=username:password -t % --remove-and-delete

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM