delete a file 
Author Message
 delete a file

How do I do something like this from rexx:
c:\>del 'd:\123\__f.abc'
where __ are empty spaces
I tried ' del "'filename'" ' in the rexx cmd but the interpreted
complained when I tried to run it.
How to make del interpret filename as a string instead of deleting the
d:\123\ directory instead?
TIA.


Fri, 09 Feb 2001 03:00:00 GMT  
 delete a file

Quote:
> How do I do something like this from rexx:
> c:\>del 'd:\123\__f.abc'
> where __ are empty spaces
> I tried ' del "'filename'" ' in the rexx cmd but the interpreted
> complained when I tried to run it.
> How to make del interpret filename as a string instead of deleting the
> d:\123\ directory instead?
> TIA.

Try this code:

/* deletes a file */
filename = 'd:\123\"   f.abc"'
Del filename

------------------------------------------------------------------
Oliver Poggensee the developer of Tyra2
The Config.sys editor for OS/2

software.freepage.de/poggensee
Please remove NOSPAM from my email address



Fri, 09 Feb 2001 03:00:00 GMT  
 delete a file


Quote:
>How do I do something like this from rexx:
>c:\>del 'd:\123\__f.abc'
>where __ are empty spaces
>I tried ' del "'filename'" ' in the rexx cmd but the interpreted complained
>when I tried to run it.
>How to make del interpret filename as a string instead of deleting the
>d:\123\ directory instead?
>TIA.

I haven't tried it with the above configuration, but have you looked at the
SysFileDelete() function in REXXUTIL (or course, if you are not running
under OS/2, this is about useless).  It should be able to do what you want,
probably something like

rc = SysFileDelete("a test file.txt")

does work, but I haven't got it to take a variable with embedded blanks yet.
Should work though.  Just have to find the right calling convention.

--

I was there at the birth of ClickWare...
--------------------------------------------------------------

Check out DefTool for AWE:
<http://www.olywa.net/kb7nmu/awe/>

--------------------------------------------------------------

Resident.  As such it is Illegal to send certain types of Unsolicited
Commercial Email to this account.  Please see
http://www.wa.gov/ago/junkemail  for more details.
--------------------------------------------------------------



Fri, 09 Feb 2001 03:00:00 GMT  
 delete a file
Yes...you are right, Rupert.
What Li Chee Yen said he tried seems to work for me.
With a file named "d:\temp\  foo.txt" and delfoo.rex like this:

trace r
filename = "d:\temp\  foo.txt"
'del "'filename'" '

the file gets deleted.
- Peter

Quote:
> -----Original Message-----

> Sent: Monday, August 24, 1998 10:01 AM

> Subject: Re: delete a file

> Assuming filename contained  d:\123\__f.abc that is what he
> did!

> The command was delimited by apostrophes and contained
> quotes either side of filename.

> Was there really a blank preceding the DEL command as
> the example suggests?  Will NT reject that?

> What was the EXACT error message?  Try trace 'C' to see the
> command as it happens.

> Rupert

> >NT wants doublequotes around the file name, so
> >'del "d:\123\__f.abc" '
> >or
> >"del ""d:\123\__f.abc"" "

> >> I tried ' del "'filename'" ' in the rexx cmd but the interpreted
> >> complained when I tried to run it.
> >> How to make del interpret filename as a string instead of
> deleting the
> >> d:\123\ directory instead?



Fri, 09 Feb 2001 03:00:00 GMT  
 delete a file
NT wants doublequotes around the file name, so
'del "d:\123\__f.abc" '
or
"del ""d:\123\__f.abc"" "
does the trick.
- Peter
Quote:
> -----Original Message-----

> Sent: Monday, August 24, 1998 6:33 PM

> Subject: delete a file

> How do I do something like this from rexx:
> c:\>del 'd:\123\__f.abc'
> where __ are empty spaces
> I tried ' del "'filename'" ' in the rexx cmd but the interpreted
> complained when I tried to run it.
> How to make del interpret filename as a string instead of deleting the
> d:\123\ directory instead?
> TIA.



Fri, 09 Feb 2001 03:00:00 GMT  
 delete a file
Assuming filename contained  d:\123\__f.abc that is what he
did!

The command was delimited by apostrophes and contained
quotes either side of filename.

Was there really a blank preceding the DEL command as
the example suggests?  Will NT reject that?

What was the EXACT error message?  Try trace 'C' to see the
command as it happens.

Rupert

Quote:
>NT wants doublequotes around the file name, so
>'del "d:\123\__f.abc" '
>or
>"del ""d:\123\__f.abc"" "
>> I tried ' del "'filename'" ' in the rexx cmd but the interpreted
>> complained when I tried to run it.
>> How to make del interpret filename as a string instead of deleting the
>> d:\123\ directory instead?



Fri, 09 Feb 2001 03:00:00 GMT  
 delete a file

Quote:
>filename = "d:\temp\  foo.txt"
>'del "'filename'" '

>the file gets deleted.

or possibly:

/* rexx */
'del "d:\temp\  foo.txt"'



Sat, 10 Feb 2001 03:00:00 GMT  
 delete a file
Hi,
I can't get your solution to work.  Actually this is what I've been
trying.  I thought all I need is to append double quotes before and after
the filename variable but that didn't work.  Anyone knows why can't it
work?
filename = "d:\temp\  foo.txt"
'del "'filename'" '
The interpreter complained that the filename contains some incorrect
characters....

The other way that Oliver pointed out works:
filename = 'd:\123\"   f.abc"'
Del filename

But now back to my problem.  The filename variable in my program can be
the full path name of any file in a directory.  The filename is passed to
my program as one string - "d:\123\  f.abc".  Do I have to break the
string up and form a new string by inserting single and double quotes as
above?  Is there an easier way?



Sat, 10 Feb 2001 03:00:00 GMT  
 delete a file

Quote:

> The other way that Oliver pointed out works:
> filename = 'd:\123\"   f.abc"'
> Del filename

> But now back to my problem.  The filename variable in my program can be
> the full path name of any file in a directory.  The filename is passed to
> my program as one string - "d:\123\  f.abc".  Do I have to break the
> string up and form a new string by inserting single and double quotes as
> above?  Is there an easier way?

No there is no easier way!
The del command excepts only the file in double quotes. Without the
qoutes
del interprets d:\123\ as the file to delete and f.abc as a parameter.
And
since f.abc is NOT a parameter for the del command you get an error.

Here is a sample code to break up the string.
/* filename contains d:\123\   f.abc */

drive = Filespec("D", filename)
path = Filespec("P", filename)
file = Filespec("N", filename)
filename = drive || path || '"' || file || '"'

----------------------------------------------------------------------
-
Oliver Poggensee the developer of Tyra2
The Config.sys editor for OS/2

software.freepage.de/poggensee
Please remove NOSPAM from my email address



Sat, 10 Feb 2001 03:00:00 GMT  
 delete a file
I don't understand your point - I have often deleted files with
blanks that are not in the current directory.  I usually use
something like del "c:\directory\name with blanks in.txt".  I
have also used del c:\directory\"name with blanks in.txt".
THIS WORKS under two versions of W95 (and NT and OS/2 if I
remember correctly).

Whatever, if you build the command correctly Rexx
should send it to the system correctly!!

A small point on the quoted message below - in Rexx,
an external command such as "DEL" in quotes is safer than
DEL without, as DEL without is a variable.  It /could/ contain
anything, or cause a Signal On NoValue to be activated.

Rupert
----------

Quote:

>Sent:  25 August 1998 09:45

>> The other way that Oliver pointed out works:
>> filename = 'd:\123\"   f.abc"'
>> Del filename

...
Quote:
>Here is a sample code to break up the string.
>/* filename contains d:\123\   f.abc */

>drive = Filespec("D", filename)
>path = Filespec("P", filename)
>file = Filespec("N", filename)
>filename = drive || path || '"' || file || '"'



Sat, 10 Feb 2001 03:00:00 GMT  
 delete a file

on 24 Aug 98  18:32:59 about delete a file...

Quote:
> How do I do something like this from rexx:
>c:\>del 'd:\123\__f.abc'
> where __ are empty spaces
> I tried ' del "'filename'" ' in the rexx cmd but the interpreted
> complained when I tried to run it.
> How to make del interpret filename as a string instead of deleting the
> d:\123\ directory instead?

If the filename has spaces in it as you indicated, then do this:

path='d:\123'
name='  f.abc'
file='"'||path||name||'"'
'del '||file

Mike Ruskai SA/AG #1106

... alt.rush.limbaugh.what.a.big.fat.dork



Sun, 11 Feb 2001 03:00:00 GMT  
 delete a file

Quote:
>above?  Is there an easier way?

Of course there is an obvious answer: don't put spaces following or
preceding the "\". Simple. If you are having these problems with a weird
filename it is better to change the filename then to find a goofball way
around it. Don't make it more complicated than it needs to be.

By the way it helps to give more info when you ask a question:
- what OS are you using?
- what REXX interpreter are you using?
- and why the hell are you placing spaces after the "\" anyhow?



Sun, 11 Feb 2001 03:00:00 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Delete all files in Dir or delete Dir

2. deleting a file

3. Recover Deleted DBX file

4. Deleted .app File.. Need help desperately

5. remove/delete disk files

6. Delete INI File Section

7. delete temp files in CPD2110 app

8. How to delete all files in a folder from within app

9. Delete readonly files with c++

10. Deleting a file

11. CW2.003 - how to delete a file?

12. Delete a File

 

 
Powered by phpBB® Forum Software