在Windows的.txt文件中复制文件夹中的文件,但不包括其中的一些文件

时间:2018-11-28 05:45:58

标签: windows macos copy delete-file

我有许多名为img-1 img-2 ... etc的图像和json文件。在一个文件夹中,我想复制它们,但不包括txt文件中的一些数字,例如: 100 1001 20345 或者只是复制所有这些文件,然后将其从.txt文件中删除 我仅拥有Windows7和Mac,而且由于找到了命令robotcopy,所以我不知道如何启动它。我知道这个问题有点简单,但是我需要一些提示来开始。

1 个答案:

答案 0 :(得分:0)

python答案:     导入操作系统     计数= 100000     x =列表(范围(1,计数+1))         text_file = open(“ delete.txt”,“ r”)         del_imgs = text_file.readlines()         对于del_imgs中的del_img:             t = del_img.split(“ \ n”)             img_path =“ D:/ images / img-” + t [0] +“。bmp”             json_path =“ D:/ images / img-” + t [0] +“。json”             os.remove(img_path)

顺便问一下,哪种方法会更快?批处理脚本还是c&c ++?