Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi,
I am trying to make a testing batch file for my 8 servers where if any new file comes my batch file will intimate me. so i have made a test batch file but i don't know how to go through it. here is the batch file:
==========================================
@echo off
SET K="C:\Documents and Settings\Administrator\Desktop\test\test":SHOW
ECHO.
ECHO.
ECHO --- BELOW LISTED FILES ARE NEWLY ADDED ---
ECHO.
ECHO.:GEN
cd "%k%"
for /f "tokens=* delims= " %%a in ('dir /B /O:-D *.*') do (
find "%%a" < "C:\Docume~1\Admini~1\Desktop\test\test\dir.txt" > nul
if errorlevel 1 echo %%a
)pause>nul
:test1
::cd "C:\Documents and Settings\Administrator\Desktop\test"
dir /b > "C:\Documents and Settings\Administrator\Desktop\test\test\dir.txt"
ECHO.
ECHO.
set /p l= Do You Want To Copy Newely Added Files To Its Respective Folder (Y or N) :
IF NOT '%l%'=='' set choice=%l:~0,1%
IF /I '%choice%'=='y' GOTO copy1
IF /I '%choice%'=='n' GOTO eof
ECHO.
pause>NUL:copy1
move /y %%a "C:\Documents and Settings\Administrator\Desktop\test"
:: Change the following anyway you see fit.
GOTO :Choices:Choices
echo.
echo.
echo.
CLS
echo 1. TESTING CHOICE
ECHO.
echo 2. TESTING CHOICE2
ECHO.
echo 3. TESTING CHOICE3
echo.set /p choice=Please choose a number:
IF NOT '%choice%'=='' set choice=%choice:~0,1%
IF '%choice%'=='1' GOTO choice1
IF '%choice%'=='2' GOTO choice2
IF '%choice%'=='3' GOTO choice3
ECHO.
pause>NULGOTO :Choices
:choice1
ECHO.
ECHO.
echo You chose 1
ECHO.
ECHO.
pause
exit:choice2
ECHO.
ECHO.
echo You chose 2
ECHO.
ECHO.
pause
exit:choice3
ECHO.
ECHO.
echo You chose 3
ECHO.
ECHO.
pause==============================
Problem 1
ECHO --- BELOW LISTED FILES ARE NEWLY ADDED --- <------ how to i set this line in batch file so that if any new files are added to the location it will generate this line otherwise say it will tell me no files are added something like that.Problem 2
what I need to add so that it will fit in my choice labels and will ask me likedo you want to copy newely added files to another location?
do you want to cut newely added files to another location?
do you want to delete the newely added files from server?what code do i need so that it it asks me like
do you want to copy newely added files to another location? <----- after selecting YES it will copy only newely added file not the older ones
K2™
System/Network Engineer

Assuming you don't want to differentiate between 'newly created' and 'newly modified,' you can use the archive file attribute.
ECHO --- BELOW LISTED FILES ARE NEWLY ADDED --- <------ how to i set this line in batch file so that if any new files are added to the location it will generate this line otherwise say it will tell me no files are added something like that.
dir /aa-d >NUL 2>&1 &&(ECHO --- BELOW LISTED FILES ARE NEWLY ADDED ---
dir /aa-d /b) || ECHO Nothing newdo you want to copy newely added files to another location? <----- after selecting YES it will copy only newely added file not the older ones
XCOPY /M /H /I *.* "\Somewhere else"

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |