[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
回复 15# idwma
中间删了很多,不然太长
     Volume in drive \\btssvr9\pds1 is btssvr9 d
Volume Serial Number is B410-9C31

Directory of \\btssvr9\pds1\cj10\3d\eqp_dgn

07/09/2021  10:12 AM            19,456 a_b.dgn
02/01/2013  02:23 PM             3,612 E210AY3102.drv
05/17/2021  05:20 PM           613,376 su_v310.dgn
05/17/2021  05:20 PM             1,461 SU_V310.drv
             264 File(s)     69,509,689 bytes
               0 Dir(s)  242,106,290,176 bytes free

TOP

回复 16# jave000


    虽然有5列多了一列,时间的位置一样的没有输出内容奇怪,确定这里面有今天的新文件吗

@echo off&setlocal enabledelayedexpansion
set/p XXX=输入XXX具体名称
set/p t=填写分钟数:
for /f "tokens=1,2 delims=: " %%i in ('time/t') do set/a tn=10000%%i*60+10000%%j
set/a tn=!tn!-!t!
set "p1=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "p2=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "d=!USERPROFILE!\Desktop\SPR\!XXX!"
for %%a in (%p1% %p2%) do (
        for /f "tokens=2,5* delims= " %%i in ('dir/a-d "%%a" ^|find "!date:~0,10!"') do (
                if "%%i" == "" (echo !date!没有今天的文件) else (echo 发现一个今天的文件%%j)
                set tf=%%i
                set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
                if "!tf!" gtr "!tn!" (echo copy "%%a\%%j" "!d!" /y) else (echo 没有!t!分钟内的文件)
        )
)
pause
1

评分人数

TOP

回复 17# idwma


    set "p1=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "p2=\\btssvr9\pds1\!XXX!\3d\pipe_dgn"

还是没有反应,你这个时间区分创建时间和更新时间吗?好像不区分吧

TOP

回复 7# newswan


    修改成更新时间后运行成功了,谢谢

TOP

回复 18# jave000


    默认的是用的修改时间,还是没反应尴尬了这就不知道了

TOP

回复 20# idwma


    我明天试试删除所有表达时间的代码,只是单纯的复制文件看看有没有反应

TOP

回复  jave000


    虽然有5列多了一列,时间的位置一样的没有输出内容奇怪,确定这里面有今天的新文件吗 ...
idwma 发表于 2021-7-14 18:13


在家用自己电脑测试了下,以下是运行状态:
中文都改成几个大写字母了

    C:\Users\Siren>D:\2.BAT

C:\Users\Siren>setlocal enabledelayedexpansion

C:\Users\Siren>set/p XXX=input
input123

C:\Users\Siren>set/p t=min
min22

C:\Users\Siren>for /F "tokens=1,2 delims=: " %i in ('time/t') do set/a tn=10000%i*60+10000%j

C:\Users\Siren>set/a tn=1000022*60+1000013

C:\Users\Siren>set/a tn=!tn!-!t!

C:\Users\Siren>set "p1=D:\Downloads\!XXX!\789"

C:\Users\Siren>set "p2=D:\Downloads\!XXX!\456"

C:\Users\Siren>set "d=!USERPROFILE!\Desktop\!XXX!"

C:\Users\Siren>for %a in (D:\Downloads\123\789 D:\Downloads\123\456) do (for /F "tokens=2,5* delims= " %i in ('dir/a-d "%a" |find "!date:~0,10!"') do (
if "%i" == "" (echo !date!NO )  else (echo ONE%j )
set tf=%i
set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
if "!tf!" GTR "!tn!" (echo copy "%a\%j" "!d!" /y )  else (echo NOT )
) )

C:\Users\Siren>(for /F "tokens=2,5* delims= " %i in ('dir/a-d "D:\Downloads\123\789" |find "!date:~0,10!"') do (
if "%i" == "" (echo !date!NO )  else (echo ONE%j )
set tf=%i
set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
if "!tf!" GTR "!tn!" (echo copy "D:\Downloads\123\789\%j" "!d!" /y )  else (echo NOT )
) )

C:\Users\Siren>(
if "22:10" == "" (echo !date!NO )  else (echo ONE )
set tf=22:10
set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
if "!tf!" GTR "!tn!" (echo copy "D:\Downloads\123\789\" "!d!" /y )  else (echo NOT )
)
ONE
copy "D:\Downloads\123\789\" "C:\Users\Siren\Desktop\123" /y

C:\Users\Siren>(for /F "tokens=2,5* delims= " %i in ('dir/a-d "D:\Downloads\123\456" |find "!date:~0,10!"') do (
if "%i" == "" (echo !date!NO )  else (echo ONE%j )
set tf=%i
set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
if "!tf!" GTR "!tn!" (echo copy "D:\Downloads\123\456\%j" "!d!" /y )  else (echo NOT )
) )

C:\Users\Siren>(
if "22:05" == "" (echo !date!NO )  else (echo ONE- )
set tf=22:05
set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
if "!tf!" GTR "!tn!" (echo copy "D:\Downloads\123\456\-" "!d!" /y )  else (echo NOT )
)
ONE-
copy "D:\Downloads\123\456\-" "C:\Users\Siren\Desktop\123" /y

C:\Users\Siren>(
if "22:05" == "" (echo !date!NO )  else (echo ONE- )
set tf=22:05
set/a tf=10000!tf:~0,2!*60+10000!tf:~3,2!
if "!tf!" GTR "!tn!" (echo copy "D:\Downloads\123\456\-" "!d!" /y )  else (echo NOT )
)
ONE-
copy "D:\Downloads\123\456\-" "C:\Users\Siren\Desktop\123" /y

TOP

回复 22# jave000


    日期和文件名位置不一样,系统时间12小时制和24小时又不一样,试一下这次的
@echo off&setlocal enabledelayedexpansion
set/p XXX=input
set/p t=min
set tn=!time: =0!
set/a tn=10000!tn:~0,2!*60+10000!tn:~3,2!
set/a t=!tn!-!t!
set "p1=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "p2=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "d=!USERPROFILE!\Desktop\SPR\!XXX!\"
echo !date!|findstr /i "[a-z]">nul && set dt=!date:~4,10! || set dt=!date:~0,10!
for %%a in (%p1% %p2%) do (
for /r "%%a" %%b in (*.*) do (
echo %%~tb | find "PM">nul && (set tf=%%~tb & set/a tf=(10000!tf:~11,2!+12)*60+10000!tf:~14,2!) || (set tf=%%~tb & set/a tf=10000!tf:~11,2!*60+10000!tf:~14,2!)
set df=%%~tb
if "!dt!" == "!df:~0,10!" if "!tf!" gtr "!t!" echo copy "%%b" "!d!" /y
)
)

TOP

回复 23# idwma


    C:\Users\Siren>d:\2.bat

C:\Users\Siren>setlocal enabledelayedexpansion

C:\Users\Siren>set/p XXX=input
input123

C:\Users\Siren>set/p t=min
min123

C:\Users\Siren>set tn=!time: =0!

C:\Users\Siren>set/a tn=10000!tn:~0,2!*60+10000!tn:~3,2!

C:\Users\Siren>set/a t=!tn!-!t!

C:\Users\Siren>set "p1=D:\Downloads\!XXX!\789"

C:\Users\Siren>set "p2=D:\Downloads\!XXX!\456"

C:\Users\Siren>set "d=!USERPROFILE!\Desktop\!XXX!"

C:\Users\Siren>echo !date!  | findstr /i "[a-z]"  1>nul  && set dt=!date:~4,10!   || set dt=!date:~0,10!
此时不应有 *60+10000!tf:~14。

C:\Users\Siren>echo %~tb | find "PM">nul && (set tf=%~tb & set/a tf=(10000!tf:~11,2!+12)*60+10000!tf:~14,2!) || (set tf=%~tb & set/a tf=10000!tf:~11,2!*60+10000!tf:~14,2!)

TOP

又踩了两个雷,for /r 的路径不能用上个循环的变量,括号里的括号要转义
@echo off&setlocal enabledelayedexpansion
set/p XXX=input
set/p t=min
set tn=!time: =0!
set/a tn=10000!tn:~0,2!*60+10000!tn:~3,2!
set/a t=!tn!-!t!
set "p1=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "p2=\\btssvr9\pds1\!XXX!\3d\eqp_dgn"
set "d=!USERPROFILE!\Desktop\SPR\!XXX!\"
echo !date!|findstr /i "[a-z]">nul && set dt=!date:~4,10! || set dt=!date:~0,10!
for %%a in ("%p1%" "%p2%") do (
pushd "%%a"
for /r  %%b in (*.*) do (
echo %%~tb | find "PM">nul && (set tf=%%~tb & set/a tf=^(10000!tf:~11,2!+12^)*60+10000!tf:~14,2!) || (set tf=%%~tb & set/a tf=10000!tf:~11,2!*60+10000!tf:~14,2!)
set df=%%~tb
if "!dt!" == "!df:~0,10!" if "!tf!" gtr "!t!" echo copy "%%b" "!d!" /y
)
popd
)

TOP

$sour = "D:\~","\\PC\Downloads"
$dest = "D:\xxx"
do
{
    $minute = read-host "多少分钟之内"
    $minute = $minute.trim()
}
while ($minute -match "\D")

Get-ChildItem -Path $sour -File |
    Where-Object { ($_.CreationTime -gt (get-date).AddMinutes(-$minute)) -or ($_.CreationTime -gt (get-date).AddMinutes(-$minute)) } |
    foreach-object {
        write-host $_.fullname
        copy-item $_.fullname -Destination $dest
    }

TOP

返回列表