|
Answer» Hi all,
I have two folders A & B. I want to SEARCH for a PARTICULAR file from Folder A in Folder B, if is present, copy that file from Folder B to Folder C. If it is not Present copy that file from Folder A to Folder D.
Please help me in searching for the files... I...SMELL something fishy. What would be the use of that, can't you just right click > make new folder?FOUR folders:
A
B
C
D
if a file from folder A exists in B, copy it from folder B to C. otherwise copy it from folder A to D.
Sounds to me like you want the end result to be:
Folder C: Contains all files from B that don't exist in A. Folder D: Contain All files in A that also exist in B.
I see nothing fishy about this myself. As such:
Code: [Select]set A="C:\FolderA" set B="C:\FolderB" set C="C:\FolderC" set D="C:\FolderD"
for %%P in (%A%\*.*) do if exist %B%\%%P copy %%P %C% for %%P in (%A%\*.*) do if not exist %B%\%%P copy %A% %D%
It could be made much better, by one of the other more NT command proficient members, but it should do what you need. Just remember to change the folder names at the top of the code to the APPROPRIATE paths.
|