Detect New Added Files In Folders&Subfolders

April 15, 2010 at 11:56:08
Specs: Windows XP
Hi All,
I have a requirement, copy only new added files from a folder and
its subfolders to
other folder.
I have in TestFolder1 as follows
C:\TestFolder1
File1.txt-->oldfile(added 7 days back)
File2.txt-->newfile(added today)
Subfolder-1
File3.txt-->oldfile(added 7 days back)
File4.txt-->newfile(added today)
Subfolder-2
File5.txt-->oldfile(added 7 days back)
File6.txt-->newfile (added today)
I want in TestFolder2 to copy only new added files. (TestFolder2 is
created already)

C:\TestFolder2
File2.txt-->newfile
File4.txt-->newfile
File6.txt-->newfile
Can you please send a sudo code batch script.

Thanks.


See More: Detect New Added Files In Folders&Subfolders

Report •

#1
April 15, 2010 at 12:04:23
There are a few ways to think about this.

Copy files with today's date.

Copy only files not already in dest folder.

Copy if later version.


=====================================
Helping others achieve escape felicity

M2


Report •

#2
April 15, 2010 at 12:12:02
Hi M2,

Thanks for responding.

i need Copy only files not already in dest folder.

like if any file is added newly to source folder then copy that
file in that destination folder.

Thanks.


Report •

#3
April 15, 2010 at 12:21:42
not tested
===========================
@echo off & setLocal EnableDELAYedeXpansion

pushd C:\TestFolder1
for /f "tokens=* delims= " %%a in ('dir/b/s/a-d') do (
if not exist C:\TestFolder2\%%Na%%Xa (
copy %%a C:\TestFolder2
)
)


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
April 15, 2010 at 13:18:22
Hi M2,

I ran the script, it is copying only old files, it is not copying
the new files

here it is the ouptput

C:\Documents and Settings\bhattu>an.bat
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
1 file(s) copied.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.
The system cannot find the file specified.

Here is the input and output files

TTestFolder1
5.0.n.txt------>old file
5.0.RC.txt------>old file
5.0.txt------>old file
50ren.txt------>old file
6.0.txt------>old file
6.1.txt------>old file
60.txt------>old file
7.0.5.txt------>old file
7.0.6.txt------>old file
Copy of 7.0.6.txt------>new file
New Folder
150ren.txt------>new file
17.0.5.txt------>new file
17.0.6.txt------>new file


TestFolder2
5.0.n.txt------>old file
5.0.RC.txt------>old file
5.0.txt------>old file
50ren.txt------>old file
6.0.txt------>old file
6.1.txt------>old file
60.txt------>old file
7.0.5.txt------>old file
7.0.6.txt------>old file


i want as
TestFolder2
Copy of 7.0.6.txt------>new file
150ren.txt------>new file
17.0.5.txt------>new file
17.0.6.txt------>new file

Thanks.


Report •

#5
April 16, 2010 at 03:04:40
It would surprise if all of XCOPY, Robocopy or XXCOPY would not be able to do what is requested. At least one has an option to only copy new files, ignoring existing (older or same or newer) files on target.

Report •

Ask Question