我是新手,我正在尝试获取一个 VBScript(因为应用程序仅适用于此),它会备份几个目录和文件......
例子:
Check if Folder1 exist... (It may be on c:\ or another drive)
If don´t exist the finish
If exist than should create a Bck Folder
THan Backup the folders that are inside folder1 (Folder2, Folder3)
Also backup all the files that are *.mds, *.vbs inside Folder4
The script have to maintain the struture...
And after that delete all folder1
这是我到目前为止所拥有的:
IF NOT EXIST "%INSTALLDIR%\Folder1\" GOTO ENDPROG
mkdir "%INSTALLDIR%\BCK\"
mkdir "%INSTALLDIR%\BCK\DADOS\"
mkdir "%INSTALLDIR%\BCK\IMAGEM\"
mkdir "%INSTALLDIR%\BCK\CONFIG\"
mkdir "%INSTALLDIR%\BCK\OFFBck"
copy "%INSTALLDIR%\Folder1\Dados*.MDB" "%INSTALLDIR%\BCK\dados\"
copy "%INSTALLDIR%\Folder1\Dados*.MDD" "%INSTALLDIR%\BCK\dados\"
copy "%INSTALLDIR%\Folder1\Dados*.VEI" "%INSTALLDIR%\BCK\dados\"
copy "%INSTALLDIR%\Folder1\Imagem*.*" "%INSTALLDIR%\BCK\Imagem\"
copy "%INSTALLDIR%\Folder1*.cfg" "%INSTALLDIR%\BCK\Config\"
copy "%INSTALLDIR%\Folder1\OFFbck*.ZIP" "%INSTALLDIR%\BCK\OFFbck\"
copy "%INSTALLDIR%\Folder1\Folder1\OFFbck*.ZIP" "%INSTALLDIR%\BCK\OFFbck\"
rmdir "%INSTALLDIR%\Folder1" /s /q
:ENDPROG
任何人都可以帮我解决这个问题吗?
我已经这样做了.....但是如果备份的文件夹已经存在,我会给出错误....但是我无法开始复制....
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\Folder1") Then
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const OverwriteExisting = TRUE
Set objFolder = objFSO.CreateFolder("C:\BCK")
Set objFolder = objFSO.CreateFolder("C:\BCK\Imagem")
Set objFolder = objFSO.CreateFolder("C:\BCK\dados")
Set objFolder = objFSO.CreateFolder("C:\BCK\config")
Set objFolder = objFSO.CreateFolder("C:\BCK\off")
Else
End If
提前致谢
我刚刚创建了这个......
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FolderExists("C:\audatex") Then
Const OverwriteExisting = True
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.CreateFolder("C:\BCK")
Set objFolder = objFSO.CreateFolder("C:\BCK\Imagem")
Set objFolder = objFSO.CreateFolder("C:\BCK\dados")
Set objFolder = objFSO.CreateFolder("C:\BCK\WTB")
Set objFolder = objFSO.CreateFolder("C:\BCK\CFG")
Set objFolder = objFSO.CreateFolder("C:\BCK\config")
Set objFolder = objFSO.CreateFolder("C:\BCK\offdaten")
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\offdaten\*.zip" , "c:\BCK\Offdaten\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\Dados\*.vei" , "c:\BCK\dados\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\Dados\*.mdd" , "c:\BCK\dados\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\*.cfg" , "c:\BCK\CFG\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\Dados\*.mdb" , "c:\BCK\dados\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFolder "C:\Audatex\Imagem" , "c:\BCK\Imagem" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\WTB\*.wtb" , "c:\BCK\WTB\" , OverwriteExisting
Set objFSO = CreateObject("Scripting.FileSystemObject")
objFSO.CopyFile "C:\Audatex\WTB\*.dtb" , "c:\BCK\WTB\" , OverwriteExisting
End IF
但是知道我有以下问题:如果文件夹上没有任何内容,我会收到错误消息,我无法覆盖文件夹
谢谢