Monday, January 17, 2011

Copy files by passing Variables in batch file.

For regular DBA activities, we should also be aware of some Windows commands as well.
We will be copying files from one location to another for which batch file would be easier way to do so without commiting mistakes.

Open notepad copy the below script and save it as a batch file (.BAT) extension.

@echo off
echo "Enter Source"
set /p source=
echo "Enter Destination"
set /p destination=
xcopy %Source% %destination%


run the batch file.

Also to extend this, if you want to copy only specific date of file or files that are new in any particular folder use

xcopy %Source% %destination% /D:00:01 by default its value is 1day older to the current date.
xcopy the command that is used to copy file.

1 comment:

  1. Good one it really help me, this is exactly I was looking to

    ReplyDelete