自动把SD卡里的录像拷贝到指定目录
搞了个行车记录仪。
双击批处理,自动把今天录得,拷贝到指定目录。省得我自己每天去翻目录,备份了。
@echo off
setlocal enabledelayedexpansion
set "targetDirectory=E:\DCIM\100MEDIA"
set "baseDestinationDirectory=D:\SARGO\2023"
REM 获取今天的日期
for /f "usebackq tokens=1 delims=" %%a in (`wmic os get localdatetime ^| findstr /r [0-9]`) do (
set "datetime=%%a"
)
set "today=!datetime:~0,8!"
set "destinationDirectory=%baseDestinationDirectory%\%today%"
REM 创建以今天日期命名的目标目录
if not exist "%destinationDirectory%" (
mkdir "%destinationDirectory%"
)
REM 遍历目标目录中的文件
for %%F in ("%targetDirectory%\*.*") do (
REM 获取文件的修改时间
echo "%%F"
for /f "usebackq tokens=1-3 delims=/ " %%i in (`dir /t:w "%%F" ^| findstr "^[0-9]"`) do (
set "fileDate=%%i%%j%%k"
)
REM 判断文件是否是今天创建的
if "!fileDate!"=="!today!" (
echo Moving %%~nxF to the destination directory.
move "%%F" "%destinationDirectory%\"
echo "move" "%%F" "%destinationDirectory%\"
)
)
echo All today's files have been moved to the destination directory (%today%).