{"id":5798,"date":"2021-11-16T14:23:28","date_gmt":"2021-11-16T14:23:28","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=5798"},"modified":"2021-11-16T14:25:11","modified_gmt":"2021-11-16T14:25:11","slug":"batch-help-check-delete-if-files-exists","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-help-check-delete-if-files-exists\/25178.html","title":{"rendered":"Batch Help &#8211; Check &#038; Delete If Files Exists"},"content":{"rendered":"<p>Hi there<\/p>\n<p>I need some help. I thought it was a pretty easy task but ive been trying to solve this all day but to no avail! I have searched through this website trying to adapt my needs but it doesnt work.<br \/>\nSo basically I have two folders, folder 1 has all the backup files and folder 2 gets new files put in it. I need a batch file to check if the files in folder 2 have the same name in folder 1&#8230;if it does the file should be deleted from folder 2.<\/p>\n<p>Heres how I thought it should be done&#8230;so I have a FOR loop with a IF statement which does the checking and if it finds the file EXISTS in folder 1 it DELETES the file from folder 2:<\/p>\n<p>&nbsp;<\/p>\n<pre>FOR %%a in (\"C:\\Users\\user\\Desktop\\test\\folder1\\*.txt\") DO IF EXIST \"C:\\Users\\user\\Desktop\\test\\folder2\\*.txt\" DEL %%a<\/pre>\n<p>Any help is appreciated and let me know if i wasnt clear&#8230;Thanks guys!<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":8},"question-category":[55],"question_tags":[],"class_list":["post-5798","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/5798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=5798"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=5798"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=5798"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=5798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}