I am trying to compress a file using built-in Windows tools. I need to use a wildcard to read the file because the input filename changes slightly each day (to reflect the date stamp). The current batch file that I have found will ZIP up a file based on a wildcard, but it gives the resulting ZIP output file a static name.
I need it to have the exact same name as the input file.
E.g.: if the input filename is blahblahblah02132014.txt, the output filename needs to be blahblahblah02132014.zip.
Please help?
Here is my current script:
set FILETOZIP=C:\Users\<my.name>\Documents\blah*.txt
set TEMPDIR=C:\temp738
mkdir %TEMPDIR%
copy %FILETOZIP% %TEMPDIR%
echo Set objArgs = WScript.Arguments > _zipIt.vbs
echo InputFolder = objArgs(0) >> _zipIt.vbs
echo ZipFile = objArgs(1) >> _zipIt.vbs
echo CreateObject("Scripting.FileSystemObject").CreateTextFile(ZipFile, True).Write "PK" ^& Chr(5) ^& Chr(6) ^& String(18, vbNullChar) >> _zipIt.vbs
echo Set objShell = CreateObject("Shell.Application") >> _zipIt.vbs
echo Set source = objShell.NameSpace(InputFolder).Items >> _zipIt.vbs
echo objShell.NameSpace(ZipFile).CopyHere(source) >> _zipIt.vbs
echo wScript.Sleep 2000 >> _zipIt.vbs
CScript _zipIt.vbs %TEMPDIR% C:\Users\<my.name>\Documents\someArchive.zip
echo Y | del %TEMPDIR%\blah*.*
rmdir %TEMPDIR%
pause