从服务器复制文件到本地使用自动批处理命令 [英] copying files from server to local automatically using batch command

查看:634
本文介绍了从服务器复制文件到本地使用自动批处理命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要为每一天产生的日志文件特别在复制我的服务器之一,我可以访问我的地方,每天自动

I want to copy the particular logfile generated for each day in one of my server which i have access to my local daily automatically.

我prepared的批处理命令如下,但没有按预期工作。

I prepared the batch commands as follows but didn't work as expected.

呼应了

SET logfiles=\\PWWAS0015\UMS_Logs\server1\ums\service-*.log
rem set var = C:\Users\L068699\Desktop\test\src
echo %logfiles%
copy %logfiles%  C:\Users\L068699\Desktop\test\

set yesterday = [DateTime]::Today.AddDays(-1).ToString("yyMMdd")
echo %yesterday%
pause

问题是,我惨啊BLE提取所有的日志,但不能得到它像服务2015-04-17.log日志。我怎么能提取这种日志这是背后即如果有一天今天是2015年4月24日我应该得到的previous一天的日志文件服务2015-04-23.log

The problem is that I cana ble to extract all the logs but couldn't get the log which are like service-2015-04-17.log. How can I extract this kind of log which are one day behind i.e. if today is 2015-04-24 I should get the previous day log file service-2015-04-23.log

推荐答案

尝试这样的:

pushd \\PWWAS0015\UMS_Logs\server1\ums\
rem set var = C:\Users\L068699\Desktop\test\src
::echo service-*.log



for /f "usebackq" %%a in (`"powershell (Get-Date).AddDays(-1).ToString('yyyy-MM-dd')"`) do set yesterday=%%a
echo %yesterday%
copy service-%yesterday%.log C:\Users\L068699\Desktop\test\
pause

最后,你需要NET命令映射网络drivre:

Eventually you'll need NET command to map the network drivre:

NET USE  \\PWWAS0015\UMS_Logs /PERSISTENT:YES

(放净使用pushd之前,如果它不工作)

(put the net use before the pushd if it does not work)

这篇关于从服务器复制文件到本地使用自动批处理命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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