Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Scripting (https://www.askmehelpdesk.com/forumdisplay.php?f=455)
-   -   Batch file- Copy current date files (https://www.askmehelpdesk.com/showthread.php?t=347080)

  • Apr 28, 2009, 06:21 AM
    YogeshS
    Batch file- Copy current date files
    Dear experts,
    How do I create a dos batch file to copy only todays(current date) files from the directory.
  • May 10, 2009, 11:33 PM
    kbjr14
    You would need to batch files.

    First one:

    Code:

    @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):

    Code:

    @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?
  • Jun 9, 2009, 07:08 PM
    PatrickMc
    Quote:

    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" .

    Code:

    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
  • May 2, 2012, 11:39 PM
    shuaib
    How do I create a dos batch file to copy files into current date folder

  • All times are GMT -7. The time now is 05:20 PM.