-2

我正在尝试在具有当前时间戳详细信息的 Windows 中创建一个文件夹并将一些文件夹复制到其中。我尝试如下:

   bat 'for /f "tokens=2-4 delims=/ " %%i in ("%date%") do SET today_fname=%%i_%%j_%%k'
    bat 'for /f "tokens=2-4 delims=/ " %%i in ("%date%") do md today_fname'
    bat 'cd %today_fname%'
    bat 'copy "C:/Program Files (x86)/Jenkins/workspace/jenkins Pipeline/application/bin/Debug/netcoreapp2.1/os/publish"'

它最终创建一个具有时间戳名称的文件夹并将该文件夹包含复制到当前目录而不是 Cd 到新创建的文件夹我正在尝试创建一个具有名称的文件夹05_14_18_7_31并将该位置中存在的包含复制C:/Program Files (x86)/Jenkins/workspace/jenkins Pipeline/application/bin/Debug/netcoreapp2.1/os/publish05_14_18_7_31

4

1 回答 1

1

您可以尝试以下方法:

@echo off
rem Create datestamp:
set "datestamp=%date:~4,-8%_%date:~7,-5%_%date:~12,2%"
rem Request for me, if you are not using `dd/mm/yy` format, to provide another script for your occassion.
rem Create timestamp:
set "timestamp=%time:~0,2%_%time:~3,2%"
rem Create folder:
md %datestamp%_%timestamp%
xcopy /E "C:/Program Files (x86)/Jenkins/workspace/jenkins Pipeline/application/bin/Debug/netcoreapp2.1/os/publish" "%datestamp%_%timestamp%"

希望这可以帮助!

于 2018-11-29T18:59:33.847 回答