每个备份CMD的新文件夹

编程入门 行业动态 更新时间:2024-10-23 12:37:25
本文介绍了每个备份CMD的新文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试批处理备份工作服务器上的文件夹. (请参阅附件链接) 错误提示参数数量无效"

I am trying to get a batch going to backup a folder on a work server. (Please see attached link) Bat Error "invalid number of parameters"

长话短说-我需要使用脚本为每个备份命名一个新文件夹,建议使用"md new_folder",但似乎无法获取上下文或如何将其放入代码中.

Long story short - I need the script to name a new folder for each backup, which "md new_folder" was suggested, but I cannot seem to get the context or how to place it into the code.

@echo This will now create a new backup of S:\Internal Auditor\9 - September 14 @echo off :: variables set SRCFOLDER="S:\Internal Auditor\9 - September 14" set DESTFOLDER="S:\Internal Auditor\2014\9 - Sept Backup" set folder=%date:~5,2%-%date:~8,2%-%date:~0,4% set backupcmd=/W /E /H /V /C /Z /I /F /J /R /Y echo ######## PLEASE WAIT SYSTEM BACKINGUP SOME DATA######## "md new_folder" xcopy %SRCFOLDER% %DESTFOLDER% %backupcmd% echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!! @pause

任何帮助将不胜感激!

---------- 我尝试了几行代码,使我慢慢靠近:----------

---------- I tried a line of code that slowly got me closer:----------

@echo This will now create a new backup of S:\Internal Auditor\9 - September 14 @echo off :: variables set SRCFOLDER="S:\Internal Auditor\9 - September 14" set DESTFOLDER="S:\Internal Auditor\2014\9 - Sept Backup" set folder=%date:~5,2%-%date:~8,2%-%date:~0,4% md "%DESTFOLDER%\%folder%" set backupcmd=/W /E /H /V /C /Z /I /F /J /R /Y echo ######## PLEASE WAIT SYSTEM BACKING UP SOME DATA######## xcopy %SRCFOLDER% "%DESTFOLDER%\%folder%" %backupcmd% echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!! @pause

但是-我得到以下输出:

This will now create a new backup of S:\Internal Auditor\9 - September 14 Access is denied. Error occurred while processing: S:\Internal. A subdirectory or file Auditor\2014\9 already exists. Error occurred while processing: Auditor\2014\9. A subdirectory or file - already exists. Error occurred while processing: -. A subdirectory or file Sept already exists. Error occurred while processing: Sept. A subdirectory or file Backup\9/-9/-Tue already exists. Error occurred while processing: Backup\9/-9/-Tue . ######## PLEASE WAIT SYSTEM BACKING UP SOME DATA######## Invalid number of parameters !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!! Press any key to continue . . .

---------- 我尝试了一段逐渐让我靠近的代码:----------

----------EDIT 2: I tried a line of code that slowly got me closer:----------

我遵循了我在网上找到的建议和一些东西,现在到了出现一些错误的地步:

I have followed the suggestions and some things I found online, and now I am to the point where I am getting a few errors:

md "S:\Internal Auditor\~\09/12/2014" A subdirectory or file S:\Internal Auditor\~\09/12/2014 already exists.

并且:

xcopy "S:\Internal Auditor\9 - September 14 S:\Internal Auditor\2014\9 - Sept Backup\09/12/2014 /W /E /H /V /C /Z /I /F /J /R /Y /D File not found - 09/12/2014 /W /E /H /V /C /Z /I /F /J /R /Y /D

这是我的代码:

This is my code:

@echo This will now create a new backup of S:\Internal Auditor\9 - September 14 Rem Backup 9 - September 14 @echo :: variables set "SRCFOLDER=S:\Internal Auditor\9 - September 14" set "DESTFOLDER=S:\Internal Auditor\2014\9 - Sept Backup" set folder=%date:~4% md "%DESTFOLDER%\%folder%" set backupcmd=/W /E /H /V /C /Z /I /F /J /R /Y /D @echo ######## PLEASE WAIT SYSTEM BACKING UP SOME DATA######## xcopy "%SRCFOLDER% %DESTFOLDER%\%folder% %backupcmd%" @echo !!!!!!!!BACKUP COMPLETED THANKS!!!!!!!!!!!!!! @pause

此外,当我运行代码时,它将创建一个新目录〜\ 09 \ 12 \ 2014而不是所需的〜\ 09/12/2014. 澄清: 它会创建3个新的子目录,而不是一个新的子目录.

Also, when I run the code, it makes a new directory ~\09\12\2014 instead of the desired ~\09/12/2014. Clarification: It makes 3 new subdirectories instead of one new subdirectory.

推荐答案

好.有一些错误:

set SRCFOLDER="S:\Internal Auditor\9 - September 14" set DESTFOLDER="S:\Internal Auditor\2014\9 - Sept Backup"

必须为(安全方法,在SRCFOLDER和DESTFOLDER的开头添加第一引号):

Must be (safe method, adding first quote at start of SRCFOLDER and DESTFOLDER):

set "SRCFOLDER=S:\Internal Auditor\9 - September 14" set "DESTFOLDER=S:\Internal Auditor\2014\9 - Sept Backup"

更多推荐

每个备份CMD的新文件夹

本文发布于:2023-10-30 19:27:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1543780.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件夹   备份   CMD

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!