vbs如何批量压缩文件夹里的多个文件
我这有个需求是将一个文件夹里的多个excel文件压缩成一个rar包里,用vbs怎么实现呢?
先谢谢了,小弟新手,麻烦给个源码
[解决办法]
你昨天不是问过几乎一样的问题吗?压缩文件夹只需要将文件名改为文件夹名称即可。
- VB code
Option ExplicitDim strRARPath As StringDim strCompresFile As String '要压缩的文件路径Dim strTargetFile As String '压缩后的文件路径Dim retvalPrivate Sub Command1_Click() Dim strP As String Dim lngP As Long strRARPath = "C:\Program Files\WinRAR\winrar.exe" '执行压缩的可执行文件路径 strCompresFile = "C:\1" '要压缩的文件路径 strTargetFile = "C:\1.rar" '压缩后的文件路径 strP = strRARPath & " A " & strTargetFile & " " & strCompresFile '压缩命令字符串 lngP = Shell(strP, vbHide) '执行压缩命令End SubPrivate Sub Command2_Click() Dim strP As String Dim lngP As Long strRARPath = "C:\Program Files\WinRAR\winrar.exe" strTargetFile = "C:\1.rar" '压缩文件路径 strCompresFile = "C:\1\" '解压缩后文件的位置 strP = strRARPath & " X " & strTargetFile & " " & strCompresFile lngP = Shell(strP, vbHide)End Sub
[解决办法]