如何使用带有robocopy命令的时间戳记来创建具有日期和时间的文件夹 [英] How to create folder with date and time using timestamp with robocopy command

查看:435
本文介绍了如何使用带有robocopy命令的时间戳记来创建具有日期和时间的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用以下时间戳创建一个文件夹:%DATE:/=-%_%TIME :: =-%

I want to create a folder using this Timestamp: %DATE:/=-%_%TIME::=-%

我的Robocopy命令是:

My Robocopy command is :

ROBOCOPY "%BUILD_SOURCESDIRECTORY%\sourcefolder\" "\\server\destination\%date:/=-%_%time::=-%" /V

但它不起作用,出现错误:

but it is not working, getting an error:

2020-04-07T03:53:21.7269608Z ##[error]Process completed with exit code 1.
2020-04-07T03:53:21.7292925Z ##[debug]System.Exception: Process completed with exit code 1.
at Microsoft.VisualStudio.Services.Agent.Worker.Handlers.ProcessHandler.RunAsync()
at Microsoft.VisualStudio.Services.Agent.Worker.TaskRunner.RunAsync()
at Microsoft.VisualStudio.Services.Agent.Worker.StepsRunner.RunStepAsync(IStep step, CancellationToken jobCancellationToken)

注意: 我引用了以下链接,但我想创建一个带有日期和时间的文件夹.在此链接中,仅提及了日期邮票.

Note: I referred to the below link but I want to create a folder with date and time.in this link only date stamp mentioned.

如何使用Robocopy来在命令行中使用TimeStamp复制文件

如果有人有想法,请告诉我.

if anyone has an idea about, please let me know.

推荐答案

这是您的批处理文件的一行,应根据需要执行.

Here's a single line for your batch file, which should do as you need.

请注意,输入真实的源路径时,请正确拼写(sourcefolder,而不是sorcefolder),并确保其没有尾随反斜杠.您的目的地也是如此.

Please note that when you input your real source path, spell it correctly, (sourcefolder, not sorcefolder), and ensure that it doesn't have a trailing backslash. The same is true for your destination.

@For /F "Tokens=1-6Delims=/: " %%G In ('""%__AppDir__%Robocopy.exe" \: . /NJH /L|"%__AppDir__%find.exe" " 123""')Do @"%__AppDir__%Robocopy.exe" "%BUILD_SOURCESDIRECTORY%\sourcefolder" "\\server\destination\%%G-%%H-%%I_%%J-%%K-%%L" /V

显然,服务器路径必须已安装/可用,并且用户也必须具有该任务所需的权限.

这篇关于如何使用带有robocopy命令的时间戳记来创建具有日期和时间的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆