Announcement

Collapse
No announcement yet.

RENAME file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • dery yosi
    replied
    try

    SHELL " ren " + FileOut3$ + " " + FileTemp$

    Leave a comment:


  • Michael Mattias
    replied
    >then is not a technique but only a trick,

    It's a trick when someone else does it.

    It's a technique when you do it.

    Leave a comment:


  • Mel Bishop
    replied
    I don't understand what the bru-ha-ha is.

    te$ = dir$(path$ + filename.ext)
    if te$ <> "" then kill path$ + filename.ext

    A short little two-liner that works.

    Leave a comment:


  • Scott Slater
    replied
    There is an Exist function that ships with PB35. If memory serves me correctly you can find it in either DOSUNIT.bas or DIRUNIT.bas (in the EXAMPLES folder).

    Leave a comment:


  • Bud Durland
    replied
    Originally posted by Manuel Valdes View Post
    Another way to make sure your old backup doesn't longer exist is to open it as Binary, Close it, and then Kill it.
    Usually I just KILL the file then ERRCLEAR to get rid of any potential error state

    Leave a comment:


  • Manuel Valdes
    replied
    OK Tom, then is not a technique but only a trick, and certainly is not wise to use it on files others than the ones your program created. I have used it only that way.

    Best regards,
    Last edited by Manuel Valdes; 17 Oct 2009, 06:39 PM.

    Leave a comment:


  • Tom Hanlin
    replied
    Err... don't? Just don't. It is never appropriate to open a file just to detect whether it exists. Those are two entirely separate kinds of operations. I'm not going to get into a long story of doom about how confusing the two will cause your dogs to be cats, and your cats, potatoes, but you really don't want to go there.

    Leave a comment:


  • Manuel Valdes
    replied
    BTW, the same technique can be used to verify whether a file exists.

    Code:
     
    Open "B", #1, Filespec$    'This notation is not accepted by PBCC, so do not get acustomed if you plan to move.
    LF&=LOF(1)
    Close 1
    If LF&>0 Then
     Print Filespec$;" exists and it's size is ";LF&
    Else
     Kill Filespec$
     Print Filespc$;" doesn't exist"
    End If
    Last edited by Manuel Valdes; 17 Oct 2009, 06:08 PM.

    Leave a comment:


  • Michael Mattias
    replied
    BINARY? BIN?

    Real Men...
    Code:
       OPEN "B", #1, filetmps$
    MCM

    Leave a comment:


  • Robert E. Carneal
    replied
    BINARY !!!!

    That's the right word. Would you believe a teacher (Not a powerbasic teacher) told us the way to do it was:

    Open FileTemp$ for BIN as #1


    Which of course never worked for me. (Yes, I realize it is not Powerbasic's fault, but geeze, I believed this teacher!) If the teacher were alive today, I would take my laptop to his house and show him the correct format.
    Thanks, Manual. Thanks, everyone!

    Robert

    Leave a comment:


  • Manuel Valdes
    replied
    Another way to make sure your old backup doesn't longer exist is to open it as Binary, Close it, and then Kill it. This way you are not going to get an error trying to give a file an existing name, nor an error trying to KILL a non existent file.

    Open FileTemp$ for Binary as #1
    Close 1 'Now the file actually exists
    KILL FileTemp$ 'Now the file doesn't exist
    Name FileOut3$ as FileTemp$

    Regards,

    Leave a comment:


  • Mel Bishop
    replied
    Keep doing a DIR$ for AK.TMP.

    Then, if found, delete the AK.TMP file or modify the output file name to AK.T[1], AK.t[2], etc.

    Leave a comment:


  • Ian Cairns
    replied
    try NAME

    look up NAME

    Name filespec1 AS filespec2

    regards, Ian.

    Leave a comment:


  • Robert E. Carneal
    started a topic RENAME file

    RENAME file

    Suppose I have:
    FileOut3$ = "E:\LGS\States\New\" & trim$(StateArray$(StateCount,1)) & ".Dat"
    FileTemp$= "E:\LGS\States\New\" & trim$(StateArray$(StateCount,1)) & ".TMP"


    (Let's say FileOut3$ = AK.Dat)

    I am trying to rename AK.Dat to AK.TMP.


    I tried saying
    SHELL " ren FileOut3$ FileTemp$"

    I want the AK.Dat file renamed to AK.TMP

    But I get this error:
    Duplicate file name or file not found.

    How should I rename files from inside a DOS Powerbasic program please?

    Thanks.

    Robert
Working...
X