Log in

View Full Version : Batch file- Copy current date files


YogeshS
Apr 28, 2009, 06:21 AM
Dear experts,
How do I create a dos batch file to copy only todays(current date) files from the directory.

kbjr14
May 10, 2009, 11:33 PM
You would need to batch files.

First one:


@echo off
set /p destination="Destination: "
for /f %%a in ('dir') do call copyFile.bat %%a %%~ta %destination%

Second one (this is where I start getting confused):


@echo off
set today=%date:~5,15%
if %today% == %2 copy %1 %3

From what I can tell, that should work, but it doesn't quite work right. Think you can get it from there?

PatrickMc
Jun 9, 2009, 07:08 PM
How do I create a dos batch file to copy only todays(current date) files from the directory.

Here is a script. (I am assuming that when you say today's files, you mean files modified today.) It starts in directory "dir1". It copies files to "dir2" .


var str today ; set today=gettime()
cd "dir1"
var str list ; lf -n "*" ( ($fmtime >= $today) AND ($fmtime <= $today) AND ($ftype=="f") ) > $list
while ($list <> "")
do
var str file ; lex "1" $list > $file
system copy $file "dir2"
done

Script is in biterscripting ( http://www.biterscripting.com ) .

Patrick

shuaib
May 2, 2012, 11:39 PM
How do I create a dos batch file to copy files into current date folder