"Mike" <> wrote in message
news:afc27084-99a4-45d9-951d-...
>I cannot zip a file at the command line with a left paren in the file
> name. (
>
> I've use these commands to change the parens to underscores but only
> the right one gets replaced, using the same command:
> set PST_TO_ZIP_ZIPFILENAME=%PST_TO_ZIP
=_%
> set PST_TO_ZIP_ZIPFILENAME=%PST_TO_ZIP
=_%
>
> I have also tried these to no avail:
> set PST_TO_ZIP_ZIPFILENAME=%PST_TO_ZIP:^(=_%
> set PST_TO_ZIP_ZIPFILENAME=%PST_TO_ZIP:"("=_%
> set PST_TO_ZIP_ZIPFILENAME=%PST_TO_ZIP:%(=_%
> set PST_TO_ZIP_ZIPFILENAME=%PST_TO_ZIP:%%(=_%
>
> Here is the output of the Winzip command:
>
> Attempting to compress "Copy of archive2007(1).pst"
>
> PST Zipfile name: Copy of archive2007(1_.pst
> Press any key to continue . . .
> WinZip(R) Command Line Support Add-On Version 2.3 (Build 8094)
> Copyright (c) WinZip International LLC 1991-2008 - All Rights Reserved
>
>
> Error: No files were found for this operation - Nothing to do. (C:
> \Users\USERBEINGBACKEDUP\Local Settings\Application Data\Microsoft
> \Outlook\Copy of archive2007(1_.pst.zip)
> Winzip Errorlevel: 12
> .pst.zip was unexpected at this time.
> C:\WINDOWS>
>
> and when you get a "was unexpected at this time." error your script
> dies. grr.
> Can anyone suggest a way to get the replacement command to work as I
> want it to?
I have run into variations of the same problem and never found a simple
solution. For a workaround, I usually would up taking a completely different
approach. Here are a few possibilities:
- write the possibly offending filename into a text file and use a text
replacement utility to change the parens to, say, the equivalent square
brackets. GSAR.EXE, for example, allows you to specify the strings to
operate on using hex equivalents, thereby avoiding the need to try to pass a
parenthesis as a literal parameter.
- write a vbscript file that accepts a filename, uses the REPLACE function
to make the necessary changes.
/Al