提问人:Jeff M 提问时间:11/6/2023 最后编辑:Jeff M 更新时间:11/6/2023 访问量:41
Windows 批处理文件适用于家用 PC 而不是 VPS [复制]
Windows Batch File Works on Home PC Not On VPS [duplicate]
问:
这个问题在这里已经有答案了:
午夜后时间设置不正确 (4 个答案)
%date:~-4,4%%date:~-10,2%%date:~-7,2%_%time:~0,2%%time:~3,2% 是什么意思? (2 个答案)
18天前关闭。
我正在使用此批处理文件从一个文件夹中随机选择一个文件,将其移动到另一个文件夹并将文件名更改为日期。就像我说的,它适用于我的家用电脑。两台计算机都运行 Windows 10。我的 VPS 运行的是 Windows Server 2022。
@echo off
setlocal EnableDelayedExpansion
cd c:\Users\Administrator\Desktop\TCTP
set n=0
for %%f in (*.*) do (
set /A n+=1
set "file[!n!]=%%f"
)
set /A "rand=(n*%random%) %%111 +1"
copy "!file[%rand%]!" c:\Users\Administrator\Documents\TCTP_Selects
ren "c:\Users\Administrator\Documents\TCTP_Selects\*.m3u" "%date:~4,2%-
%date:~7,2%-%date:~12,2%.m3u"
需要明确的是,在VPS上,它确实选择并移动文件,只是不会将其重命名为日期。任何帮助将不胜感激!
答: 暂无答案
评论
%date:~4,2%
copy "!file[%rand%]!" "c:\Use…cts\%date:~4,2%- %date:~7,2%-%date:~12,2%.m3u"
%date%