質問

I need to move a file from all folders on all hard drives modified within two dates. Because I am new to batch, please explain what it all means.

What I want:

Search all folders in all hard drives for files modified from Nov 10, 2013 to Nov 11, 2013 Make folder in drive D:/backups/11_11 Move all files found in the scan modified with in the dates and YEAR to the folder made Create a text file with the log of all files moved, errors, and time of moved (time of moved optional)

役に立ちましたか?

解決

@ECHO OFF &SETLOCAL
set "date1=01/09/2013"
set "date2=31/10/2013"
set "SearchPath=D:/backups/11_11"
set "datestamp1=%date1:~6,4%%date1:~3,2%%date1:~0,2%"
set "datestamp2=%date2:~6,4%%date2:~3,2%%date2:~0,2%"

for %%a in ("%searchpath%\*") do (
    set "fname=%%~a"
    for /f "tokens=1-3 delims=/-. " %%b in ("%%~ta") do set "datestampF=%%~d%%~c%%~b"
    SETLOCAL ENABLEDELAYEDEXPANSION
    if "!datestampF!" gtr "%datestamp1%" if "!datestampF!" lss "%datestamp2%" echo move "!fname!" "DestinationFolder"
    endlocal
)

Remove the echo to get it working.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top