Redirect the entire command including the result to a .txt file

>%DT%.TXT 2>&1 (
xcopy E:\OUTSIDE\XFORM\%FN%.frm D:\OUTSIDE\XFORM /y
xcopy E:\OUTSIDE\XFORM\%FN%.fsl D:\OUTSIDE\XFORM /y
xcopy E:\OUTSIDE\XIMAGE\%FN%.img D:\OUTSIDE\XFORM /y
)

      

The code above is a sample of the lines that I need to redirect to a text file. This currently works with the exception that it only shows where the file is being copied and how many files are being copied.

I need to be able to redirect the entire line so that I can see where the files are copied and for management purposes. Not really sure if this is possible even through the party. Unfortunately, this is my only option at this time.

+3


source to share


1 answer


I offer two simple package solutions.

The first uses a parameter /F

as suggested by MC ND :

>>%DT%.TXT 2>&1 (
    xcopy E:\OUTSIDE\XFORM\%FN%.frm D:\OUTSIDE\XFORM /F /I /Y
    xcopy E:\OUTSIDE\XFORM\%FN%.fsl D:\OUTSIDE\XFORM /F /I /Y
    xcopy E:\OUTSIDE\XIMAGE\%FN%.img D:\OUTSIDE\XFORM /F /I /Y
)

      



The xcopy command can be read by running in a command prompt window xcopy /?

, which also explains the parameter /I

- D:\OUTSIDE\XFORM

should be interpreted as a destination folder that will be created automatically if it doesn't already exist.

The second copy repeats the source and destination before copying:

>>%DT%.TXT 2>&1 (
    echo Copying E:\OUTSIDE\XFORM\%FN%.frm to D:\OUTSIDE\XFORM
    xcopy E:\OUTSIDE\XFORM\%FN%.frm D:\OUTSIDE\XFORM /I /Y
    echo Copying E:\OUTSIDE\XFORM\%FN%.fsl to D:\OUTSIDE\XFORM
    xcopy E:\OUTSIDE\XFORM\%FN%.fsl D:\OUTSIDE\XFORM /I /Y
    echo Copying E:\OUTSIDE\XFORM\%FN%.img to D:\OUTSIDE\XFORM
    xcopy E:\OUTSIDE\XIMAGE\%FN%.img D:\OUTSIDE\XFORM /I /Y
)

      

0


source







All Articles