| 1. |
Solve : Suppressing XCOPY Message? |
|
Answer» Hi, xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" Removing the destination filename might suppress the message, it's not needed in this case. Quote from: Dusty on February 19, 2009, 12:17:33 AM Removing the destination filename might suppress the message, it's not needed in this case. Yes, that does seem more simple. GOOD solution!Hi All, Thanks for the valuable input. I should have excluded the -d in my DIR command in the FOR Loop as it is not a Flat Directory. Below is the Problem: 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. Solution: I have written the below code to search and copy the files. However i'm unable to suppress the XCOPY message: @ echo off if exist d:\%1_Backup del/Q d:\%1_Backup if exist d:\%1_Del del/Q d:\%1_Del mkdir d:\%1_Backup mkdir d:\%1_Del for /f "delims=" %%a in ('dir/b/a D:\Source') do ( if exist "D:\Destination\%%a" ( xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" /S/E/H/R/Y/F/Q/I >%2 ) ) for /f "delims=" %%a in ('dir/b/a D:\Source') do ( if not exist "D:\Destination\%%a" ( xcopy "D:\source\%%a" "D:\%1_Del\%%a" /S/E/H/R/Y/F/Q/I >%2 ) ) Pause Below is my directory structure: Source Destination Compile Compile FTP FTP ISO ISO NSR Vehicle Paint WRC Painting Tips ABC [Folder] POLK abdc POLK-jan09 Vehicle WRC ABC [Folder] abdc extra In the above directory structure, the code is not copying the contents of the folder ABC correctly. (i.e) it is copying only the folder ABC and not the contents of the folder abdc and extra. Thanks for your help. Quote from: ponnisundar on February 19, 2009, 10:30:22 PM 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. I am confused. You say you have 2 folders, but you are referring to Folder A, Folder B, Folder C and Folder D which is actually 4 folders.Quote from: ponnisundar I have written the below code to search and copy the files. However i'm unable to suppress the XCOPY message: Did you not read or understand this? Quote from: Dusty on February 19, 2009, 12:17:33 AM Quotexcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" Quote from: ponnisundar xcopy "D:\Destination\%%a" "D:\%1_Backup\%%a" /S/E/H/R/Y/F/Q/I Remove the %%a variables (only those which are emboldened and underlined) which contain the output filenames, they are not required in the Xcopy commands. This should suppress the Xcopy message. Quote from: ponnisundar In the above directory structure, the code is not copying the contents of the folder ABC correctly. (i.e) it is copying only the folder ABC and not the contents of the folder abdc and extra. Quote from: ponnisundar for /f "delims=" %%a in ('dir/b/a D:\Source') do ( The Dir command in For extracts only the names of files which are ready to archive in the Source directory, not those in subdirectories. You must include the /S switch to extract those but that will extract all the qualifying filenames in all subdirectories. Is that what you want or do you want to extract filenames only from ABC, ABCD and EXTRA. If the latter then the Dir command path should be D:\ABC\ and the /S switch must be present. I'm also confused as to your directory structure, maybe Source is a directory and all the rest are subdirectories of Source? Input Folder A - Source Folder B - Destination Output Folder C - _Backup Folder D - _Del I Just want the code to work on the folders Source and Destination and copy the contents to _Backup & _Del based on the following rule Folder C: Contains all files from B that exist in A. Folder D: Contain All files from A that do not exist in B. Thanks. Hi, I saw your input for supressing the XCOPY message. I used that and it worked. Thanks a lot for that. But i missed removing that while posting in the forum. But the problem i face now is the XCOPY is not copying the contents of folders inside the Source & Destination. Instead it is just copying the folder alone. Corrected Code: Code: [Select]@ echo off if exist d:\%1_Backup del/Q d:\%1_Backup if exist d:\%1_Del del/Q d:\%1_Del mkdir d:\%1_Backup mkdir d:\%1_Del for /f "delims=" %%a in ('dir/b/a D:\Source') do ( if exist "D:\Destination\%%a" ( xcopy "D:\Destination\%%a" "D:\%1_Backup\" /S/E/H/R/Y/F/Q/I ) ) for /f "delims=" %%a in ('dir/b/a D:\Source') do ( if not exist "D:\Destination\%%a" ( xcopy "D:\source\%%a" "D:\%1_Del\" /S/E/H/R/Y/F/Q/I ) ) Pause Thanks.Read the bottom part of my reply #8 |
|