By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,751 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

Problem with Shell and space in file name

P: n/a
I know this is an old favourite but I can't find a simple answer to a
simple question.

I'm trying to run this:

shell("c:\program files\pkware\pkzipc\pkzipc.exe -ext " & myPath &
myZIPFile & " " & myPath)

I want to unzip a file who's path name is defined by the variable
myPath and who's file name is defined by the variable myZIPFile, and
place the unzipped file in the same folder.

It fails, I presume, because of the space in 'program files'. It also
fails because in some instances there may also be a space in 'myPath',
though I can probably work round this.

So any help please on how to solve this

Thanks
Dave

Aug 7 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
The operating system expects spaces around paths that contain spaces, so try
adding the spaces to the names:

Perhaps this kind of thing:
Dim strWot2Shell As String
strWot2Shell = """c:\program files\pkware\pkzipc\pkzipc.exe"" -ext """ &
myPath & myZIPFile & """ """ & myPath & """"
Debug.Print strWot2Shell
Call shell(strWot2Shell)

Hopefully the Debug.Print will help you to get it right. (See the output in
the Immediate Window (Ctrl+G.)

If the quotes make no sense, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave G @ K2" <Da*************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
>I know this is an old favourite but I can't find a simple answer to a
simple question.

I'm trying to run this:

shell("c:\program files\pkware\pkzipc\pkzipc.exe -ext " & myPath &
myZIPFile & " " & myPath)

I want to unzip a file who's path name is defined by the variable
myPath and who's file name is defined by the variable myZIPFile, and
place the unzipped file in the same folder.

It fails, I presume, because of the space in 'program files'. It also
fails because in some instances there may also be a space in 'myPath',
though I can probably work round this.

So any help please on how to solve this

Thanks
Dave

Aug 7 '06 #2

P: n/a
Thanks Allen

Getting closer, but not quite there. I experimented with setting the
path to c:\ and putting a file in there called 72.zip which I know
containcs 2 items, one called ticket.txt and the other called 72a.jpg

The code runs, but I get a dos error of: Illegal character in filename
c:"/ticket.txt. If I supply a good file name then the code carries on

So, clearly the space in 'program files' is resolved but something else
is going on, Can you see it, because I can't !!

Thanks
Dave

Allen Browne wrote:
The operating system expects spaces around paths that contain spaces, so try
adding the spaces to the names:

Perhaps this kind of thing:
Dim strWot2Shell As String
strWot2Shell = """c:\program files\pkware\pkzipc\pkzipc.exe"" -ext """ &
myPath & myZIPFile & """ """ & myPath & """"
Debug.Print strWot2Shell
Call shell(strWot2Shell)

Hopefully the Debug.Print will help you to get it right. (See the output in
the Immediate Window (Ctrl+G.)

If the quotes make no sense, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave G @ K2" <Da*************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
I know this is an old favourite but I can't find a simple answer to a
simple question.

I'm trying to run this:

shell("c:\program files\pkware\pkzipc\pkzipc.exe -ext " & myPath &
myZIPFile & " " & myPath)

I want to unzip a file who's path name is defined by the variable
myPath and who's file name is defined by the variable myZIPFile, and
place the unzipped file in the same folder.

It fails, I presume, because of the space in 'program files'. It also
fails because in some instances there may also be a space in 'myPath',
though I can probably work round this.

So any help please on how to solve this

Thanks
Dave
Aug 7 '06 #3

P: n/a
If PkZip is a DOS program, Mypath cannot have spaces. You will need to
convert it to 8.3 format. Otherwise use a Windows based zip program, I use
WinZip.

"Dave G @ K2" <Da*************@gmail.comwrote in message
news:11*********************@b28g2000cwb.googlegro ups.com...
Thanks Allen

Getting closer, but not quite there. I experimented with setting the
path to c:\ and putting a file in there called 72.zip which I know
containcs 2 items, one called ticket.txt and the other called 72a.jpg

The code runs, but I get a dos error of: Illegal character in filename
c:"/ticket.txt. If I supply a good file name then the code carries on

So, clearly the space in 'program files' is resolved but something else
is going on, Can you see it, because I can't !!

Thanks
Dave

Allen Browne wrote:
The operating system expects spaces around paths that contain spaces, so
try
adding the spaces to the names:

Perhaps this kind of thing:
Dim strWot2Shell As String
strWot2Shell = """c:\program files\pkware\pkzipc\pkzipc.exe"" -ext
""" &
myPath & myZIPFile & """ """ & myPath & """"
Debug.Print strWot2Shell
Call shell(strWot2Shell)

Hopefully the Debug.Print will help you to get it right. (See the output
in
the Immediate Window (Ctrl+G.)

If the quotes make no sense, see:
Quotation marks within quotes
at:
http://allenbrowne.com/casu-17.html

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Dave G @ K2" <Da*************@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
>I know this is an old favourite but I can't find a simple answer to a
simple question.
>
I'm trying to run this:
>
shell("c:\program files\pkware\pkzipc\pkzipc.exe -ext " & myPath &
myZIPFile & " " & myPath)
>
I want to unzip a file who's path name is defined by the variable
myPath and who's file name is defined by the variable myZIPFile, and
place the unzipped file in the same folder.
>
It fails, I presume, because of the space in 'program files'. It also
fails because in some instances there may also be a space in 'myPath',
though I can probably work round this.
>
So any help please on how to solve this
>
Thanks
Dave

Aug 7 '06 #4

P: n/a
Yes Ron, but when myPath = "c:\" I still receive an error - see
previous message

Dave

Aug 7 '06 #5

P: n/a
What about your filename?

"Dave G @ K2" <Da*************@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Yes Ron, but when myPath = "c:\" I still receive an error - see
previous message

Dave

Aug 7 '06 #6

P: n/a
Allen Brown's example created the command line in a string and output it
with debug print. What does that lookup like? Can you test it from a command
prompt? What kind of error messages do you get from PKZip and Windows?

"Dave G @ K2" <Da*************@gmail.comwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
Yes Ron, but when myPath = "c:\" I still receive an error - see
previous message

Dave

Aug 7 '06 #7

P: n/a

Thanks for help. This is very odd. I have come to the conclusion that
providing the source zip file is in c:\ then all is well, otherwise it
doesn't work. No error messages, and the resultant string looks fine,
but it just does nothing. I haven't given up yet and will let you know
if I crack this

Dave

Aug 7 '06 #8

P: n/a

Cracked it. Thanks Allen, your solution was working all the time, but I
just didn't know it.

Cheers
Dave

Aug 8 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.