Computing.Net > Forums > Programming > Copy only newely added files

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Copy only newely added files

Reply to Message Icon

Name: alwaysk2
Date: August 26, 2008 at 20:29:10 Pacific
OS: Windows 2003 Ent. Server
CPU/Ram: 8GHZ/ 16GB
Product: IBM
Comment:

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>NUL

GOTO :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 like

do 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



Sponsored Link
Ads by Google

Response Number 1
Name: Razor2.3
Date: August 27, 2008 at 14:55:32 Pacific
Reply:

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 new

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

XCOPY /M /H /I *.* "\Somewhere else"


0

Response Number 2
Name: alwaysk2
Date: August 28, 2008 at 17:47:34 Pacific
Reply:

I am not getting dear where your stated commands do i have to put.

K2™
System/Network Engineer


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Copy only newely added files

Win2k batch: copy only new files? www.computing.net/answers/programming/win2k-batch-copy-only-new-files/10386.html

Script to copy and delete existing files www.computing.net/answers/programming/script-to-copy-and-delete-existing-files/20071.html

Copy and Rename Batch File www.computing.net/answers/programming/copy-and-rename-batch-file/15297.html