{"id":14425,"date":"2021-12-15T01:17:44","date_gmt":"2021-12-15T01:17:44","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=14425"},"modified":"2021-12-15T01:18:17","modified_gmt":"2021-12-15T01:18:17","slug":"solved-copy-all-files-if-exists-rename-copy","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/copy-all-files-if-exists-rename-copy\/21859.html","title":{"rendered":"Solved Copy All Files, If Exists, Rename &#038; Copy"},"content":{"rendered":"<p>Hi, i was wondering if somebody can point me<br \/>\nin the right direction with a problem i have, my<br \/>\nproblem is im trying to create a Batch Script<br \/>\nwhich first of all creates a new folder which will<br \/>\nbe called &#8216;Finished&#8217;, it will then go into and<br \/>\ncopy all files in sub folders into this new<br \/>\n&#8216;Finished&#8217;, simple enough, but there will be a<br \/>\nlikelyhood of files from different sub folders<br \/>\nwhich will have the exact same file name as<br \/>\nfiles which have already been copied to this<br \/>\n&#8216;Finished&#8217; folder, ive had a play around already<br \/>\nand ive noticed it just overwrites the file if they<br \/>\nhave the same file name, which is what i dont<br \/>\nwant, and thats where im stuck. i imagine id<br \/>\nwant some kind of if statement where if a file<br \/>\nhas the same file name as one that has<br \/>\nalready been copied, add a (1), (2), (3) ect<br \/>\nect.. to the end of that file name then copy it.<\/p>\n<p>Ive created a test area with some test files and<br \/>\nthis is the batch code ive come up with so far<\/p>\n<p>md Finished<br \/>\ncd folder 1<br \/>\ncopy * ..\\Finished<br \/>\ncd ..\\<\/p>\n<p>cd folder 2<br \/>\ncopy * ..\\Finished<br \/>\ncd ..\\<\/p>\n<p>Im relatively new to creating Batch files but<br \/>\nhave a better background on VBA, not sure if<br \/>\ntheres a better way than batch script?<\/p>\n<p>ANY help is much appreciated, Thanks.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":29},"question-category":[55],"question_tags":[],"class_list":["post-14425","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\/14425","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=14425"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=14425"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=14425"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=14425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}