I have many images and json files which named as img-1 img-2...etc. in a folder, and I'd like to do copy them excluding some numbers in a txt file like: 100 1001 20345 or just copy all of them and delete these from the .txt I have windows7 and mac only and I don't know how to start with it since I found the command robotcopy. I know this question is kind of simple, but I need some hints to start .
Asked
Active
Viewed 24 times
0
-
Which programming language are you using? – user202729 Nov 28 '18 at 05:48
-
@user202729 I just found how stupid I was and wrote it in python by os.remove. Since I already opened this question I want to know how to do it in batch scripts in windows. – lunasdejavu Nov 28 '18 at 06:06
-
[Similar question answered here for batch script., Check it out](https://stackoverflow.com/questions/14307075/batch-to-delete-files-that-have-their-paths-in-a-txt-file) – Vishaak M Nov 28 '18 at 06:17
1 Answers
0
python answer: import os count = 100000 x = list(range(1,count+1)) text_file = open("delete.txt", "r") del_imgs = text_file.readlines() for del_img in del_imgs: 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)
by the way,which way would be faster? batch scripts or c &c++?

lunasdejavu
- 89
- 1
- 8