我有一个批处理文件可以移动一些东西并组织它们。我想在该批次的末尾添加一些代码,将所有文件重命名为相同的名称,但除了结尾之外的日期只有数字。也许我擅长搜索,因为我发誓这已被覆盖,但我找不到它。总而言之,我需要帮助编写代码来转换最后没有日期的文件夹中的每个文件,以便将日期添加到最后。所以它需要检查最后是否有8位数字,如果没有,则添加日期。我会发布我的批处理文件,以防你需要知道我在做什么
rem @echo off
SETLOCAL enableextensions
Set dat=Date
for %%x in (*.pdf) do (
set "_pdfname=%%x"
call :doAllWork
)
goto :eof
:doAllWork
ECHO start
start %_pdfname%
TIMEOUT /T 2 /NOBREAK
start select.vbs
TIMEOUT /T 1 /NOBREAK
start copy.vbs
TIMEOUT /T 1 /NOBREAK
for /F %%g in ('
wmic OS get LocalDateTime /value^|findstr "="
') do for /F %%G in ("%%g") do set "_%%G"
echo %_LocalDateTime:~0,14%
type NUL > TextFiles\%_LocalDateTime:~0,14%.txt
start TextFiles\%_LocalDateTime:~0,14%.txt
TIMEOUT /T 2 /NOBREAK
ECHO close PDF
start close.vbs
TIMEOUT /T 2 /NOBREAK
start window.vbs
TIMEOUT /T 1 /NOBREAK
start paste.vbs
TIMEOUT /T 1 /NOBREAK
start save.vbs
TIMEOUT /T 1 /NOBREAK
start close.vbs
start enter.vbs
move /-y "%_pdfname%" "OldTimesheets\"
TIMEOUT /T 1 /NOBREAK
ECHO exit loop
if exist *.pdf (
goto :eof
) else (
goto :end
)
:end
cscript MessageBox.vbs "This will be shown in a popup."
所以在最后,OldTimesheets中的所有新PDF都需要重命名,但旧的PDF将具有它们放在那里的日期。 提前谢谢!这个社区总是很棒!
答案 0 :(得分:0)
app.use(function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Headers", "Content-Type");
res.header("Access-Control-Max-Age", "3600");
next();
});
注意:
@echo off
SETLOCAL enableDelayedExpansion
for /f "delims=" %%x in ('dir /b *.pdf') do (
call :doAllWork "%%x"
)
for /f "delims=" %%x in ('dir /b *.pdf') do (
echo %%x | findstr /r "_[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\." >nul
if errorlevel 1 ren "%%x" "%%~fx_!_LocalDateTime:~0,8!%%~nx"
)
cscript MessageBox.vbs "This will be shown in a popup."
pause
exit
:doAllWork
ECHO start
start %1
TIMEOUT /T 2 /NOBREAK & start select.vbs
TIMEOUT /T 1 /NOBREAK & start copy.vbs
TIMEOUT /T 1 /NOBREAK
for /F "delims== tokens=2" %%g in ('
wmic OS get LocalDateTime /value ^| find "="
') do set _LocalDateTime=%%g
echo !_LocalDateTime:~0,14!
type NUL > TextFiles\!_LocalDateTime:~0,14!.txt
start TextFiles\!_LocalDateTime:~0,14!.txt
TIMEOUT /T 2 /NOBREAK & ECHO close PDF & start close.vbs
TIMEOUT /T 2 /NOBREAK & start window.vbs
TIMEOUT /T 1 /NOBREAK & start paste.vbs
TIMEOUT /T 1 /NOBREAK & start save.vbs
TIMEOUT /T 1 /NOBREAK & start close.vbs & start enter.vbs
move /-y "%1" "OldTimesheets\"
TIMEOUT /T 1 /NOBREAK & ECHO exit loop
exit /b
的直接枚举替换为*.pdf
,以防止在重命名文件后重新处理文件。dir /b *.pdf
以使SETLOCAL enableDelayedExpansion
更改每个作业的值,在这种情况下也应使用_LocalDateTime
代替!
%
,因为它已默认启用答案 1 :(得分:0)
我自己想出来了!我添加了
operatorPrecedence
在乞讨和使用
set str=%date%
echo.%str%
set str=%str:/=%
echo.%str%
移动线后。奇迹般有效!不管怎样,谢谢你的帮助!