create a log of files excluded using xcopy
Moderator: DosItHelp
create a log of files excluded using xcopy
I want to have a log of only the files which xcopy excluded while copying the directories which I specified in the batch script. eg. my script is doing this
xcopy "first folder name" "second folder name" /s /i /Y /f /exclude:excludefiles.txt
I want to have a log of the files which were excluded and not copied into second folder.
xcopy "first folder name" "second folder name" /s /i /Y /f /exclude:excludefiles.txt
I want to have a log of the files which were excluded and not copied into second folder.
Re: create a log of files excluded using xcopy
We'd have to replicate the scenario - can you paste and copy the screen output where it excludes files, and a few lines above and below?
Re: create a log of files excluded using xcopy
On the screen it just shows the paths of the files copied no mention of the excluded files.
Applying Patch for "D:\Release\Client"
D:\Release\Patch_Control\PATCH_20120827\Client Release\BusinessObjects.dll -> D:\Release\Client\BusinessObjects.dll
D:\Release\Patch_Control\PATCH_20120827\Client Release\BusinessObjects.pdb -> D:\Release\Client\BusinessObjects.pdb
D:\Release\Patch_Control\PATCH_20120827\Client Release\CommonDataCache.dll -> D:\Release\Client\CommonDataCache.dll
D:\Release\Patch_Control\PATCH_20120827\Client Release\CommonDataCache.pdb -> D:\Release\Client\CommonDataCache.pdb
4 File(s) copied
Patch file:"D:\Release\Patch_Control\PATCH_20120827\Client Release" applied successfully
the first and last line are echoed in the script others are the result of xcopy.
in the above the client release folder also contains the files which have been excluded such as .xml files.
the script actually copies the patch files to the actual release and the xml files are changed manually for different releases.
In short I am getting a log of files copied instead I want a log of files not copied so that I can easily do it manually and also I have a reference.
Applying Patch for "D:\Release\Client"
D:\Release\Patch_Control\PATCH_20120827\Client Release\BusinessObjects.dll -> D:\Release\Client\BusinessObjects.dll
D:\Release\Patch_Control\PATCH_20120827\Client Release\BusinessObjects.pdb -> D:\Release\Client\BusinessObjects.pdb
D:\Release\Patch_Control\PATCH_20120827\Client Release\CommonDataCache.dll -> D:\Release\Client\CommonDataCache.dll
D:\Release\Patch_Control\PATCH_20120827\Client Release\CommonDataCache.pdb -> D:\Release\Client\CommonDataCache.pdb
4 File(s) copied
Patch file:"D:\Release\Patch_Control\PATCH_20120827\Client Release" applied successfully
the first and last line are echoed in the script others are the result of xcopy.
in the above the client release folder also contains the files which have been excluded such as .xml files.
the script actually copies the patch files to the actual release and the xml files are changed manually for different releases.
In short I am getting a log of files copied instead I want a log of files not copied so that I can easily do it manually and also I have a reference.
Re: create a log of files excluded using xcopy
Use your exclusions file to create a file list:
Assuming your exclusions file looks like this
*.xml
xyz*.avi
then this should create the exclusions list for you: (untested)
Assuming your exclusions file looks like this
*.xml
xyz*.avi
then this should create the exclusions list for you: (untested)
Code: Select all
@echo off
for /f "delims=" %%a in (exclusions.txt) do (
dir /b /s /a-d "%%a">>"skipped files.txt"
)
Re: create a log of files excluded using xcopy
my exclusion files looks like
.xml
.config
no wildcard supported in xcopy
Also the batch file is running in a different location than the directories being copied so I think this line will not work
dir /b /s /a-d "%%a">>"skipped files.txt"
.xml
.config
no wildcard supported in xcopy
Also the batch file is running in a different location than the directories being copied so I think this line will not work
dir /b /s /a-d "%%a">>"skipped files.txt"
Re: create a log of files excluded using xcopy
Then you can use this line:
dir /b /s /a-d "c:\source\folder\*%%a">>"skipped files.txt"
dir /b /s /a-d "c:\source\folder\*%%a">>"skipped files.txt"
Re: create a log of files excluded using xcopy
I did this to solve the issue
(dir /b /s /a-d "%DownloadedPatchPath%\%fold%")|findstr /g:excludefiles.txt >>"%DownloadedPatchPath%\skipped.txt"
does it have any vulnerability
(dir /b /s /a-d "%DownloadedPatchPath%\%fold%")|findstr /g:excludefiles.txt >>"%DownloadedPatchPath%\skipped.txt"
does it have any vulnerability
Re: create a log of files excluded using xcopy
No worries, you're welcome.
Re: create a log of files excluded using xcopy
Greetings all!
Another solid solution by foxidrive! Thank you sir!
If I may, I would like to indulge the forum with my solution using
Robocopy.
Caveats and Notes:
1. XP and above is required for Robocopy. If using XP then the
Resources Kit will have needed to have been installed. My thanks
to Squashman regarding the Resource Kit information.
2. I excluded *.jpg files for my own testing.
3. I had to play around with the line "echo %line:~16,65%" to allow
for long path/file names. May need further adjustment by the user.
4. Sub folders of "c:\first_folder_name" will be copied and if
"c:\second_folder_name" does not exist it will be created.
Best wishes!
Another solid solution by foxidrive! Thank you sir!
If I may, I would like to indulge the forum with my solution using
Robocopy.
Code: Select all
@echo Off
::Limited Testing using XP SR3 and ROBOCOPY Ver. XP010
::Part One. ROBOCOPY Files with some exclusions and create a log file.
ROBOCOPY c:\first_folder_name c:\second_folder_name /e /xf /ndl *.xml *.config *.jpg /v /log:skipped1.txt
::Part Two Clean up the log file created by ROBOCOPY to simulate
::a DIR listing.
type skipped1.txt | find "named">skipped2.txt
for /f "delims=" %%a in ('type "skipped2.txt"') do call :take_out %%a
del skipped?.txt
goto :eof
:take_out
setlocal
set line=%*
echo %line:~16,65%>>"skipped_files.txt"
Caveats and Notes:
1. XP and above is required for Robocopy. If using XP then the
Resources Kit will have needed to have been installed. My thanks
to Squashman regarding the Resource Kit information.
2. I excluded *.jpg files for my own testing.
3. I had to play around with the line "echo %line:~16,65%" to allow
for long path/file names. May need further adjustment by the user.
4. Sub folders of "c:\first_folder_name" will be copied and if
"c:\second_folder_name" does not exist it will be created.
Best wishes!