批处理文件范围 [英] Batch File Range

查看:149
本文介绍了批处理文件范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在先进的感谢您的帮助!我对你们的批处理文件的问题。因此,我们保持与客户的备份。他们距离我们200英里远。我们把他们的备份在通过远程桌面。我们发现,通过在命令提示符下使用复制功能远比复制/粘贴的任何其他方法更快。谁是负责把他们交给常的人忘记了这样做。我刚刚开始使用的批次,但我创建了一个小批量的程序会询问哪些文件的用户带来了,所以他并没有复制N:\\备份\\等等\\软件tsclient \\ ^ h \\备份\\嗒嗒这是相当容易出错。以下是批处理文件:

Thanks in advanced for your help! I have a batch file question for you guys. So we keep up with one of our client's backups. They're located over 200 miles away from us. We bring their backups over via remote desktop. We've found that using the copy function via the command prompt is MUCH faster than any other method of copy/paste. The person who is in charge of bringing them over often forgets to do so. I've only just started using batches, but I created a small batch program that will ask the user which file to bring over so he doesn't have to "copy n:\backups\blah \tsclient\h\backups\blah" which can be quite error prone. The following is the batch file:

@echo off
title Copy Zipbacks

:loopagain
set /p date=Enter the date that needs to be copied over (yyyymmdd format):
copy h:\zipbackups\daily%date%.zipx \\tsclient\h\benton_off_site_backup\zipbackups

set /p again=Copy Another Daily Zip file? (Y/N):

IF "%again%"=="Y" GOTO loopAgain
IF "%again%"=="N" GOTO goAway

:goAway
exit

如果没有被带过来只备份极少数是这是一件好事。我的问题是这样的;有没有办法把在一系列的备份?该文件的设置如下:

This is good if there are only a handful of backups to be brought over. My question is this; Is there a way to bring over a range of backups? The file is setup as follows:

dailyYYYYMMDD.zipx
i.e. daily20140917.zipx

我没有问题,要求的日期范围,而是通过文件夹获得.BAT循环,只让那些符合标准的就是我遇到的问题。有什么想法?

I have no problem asking for the date range, but getting the .bat to loop through the folder and getting only those that meet the criteria is where I'm running into the issue. Any thoughts?

推荐答案

您可以使用来列举文件:

You may use a for to enumerate files:

@echo off
title Copy Zipbacks

:loopagain
set /p start_date=Enter start date that needs to be copied over (yyyymmdd format):
set /p end_date=Enter end date (yyyymmdd format) or nothing to match only start date:
if not defined end_date set end_date=%start_date%
for %%f in (h:\zipbackups\daily*.zipx) do if "%%~nf" geq "daily%start_date%" if "%%~nf" leq "daily%end_date%" copy %%f \\tsclient\h\benton_off_site_backup\zipbackups

set /p again=Copy Another Daily Zip file? (Y/N):

IF "%again%"=="Y" GOTO loopAgain
IF "%again%"=="N" GOTO goAway

:goAway
exit

这篇关于批处理文件范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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