Sign in to follow this  
Followers 0
probedrone

rename files?

8 posts in this topic

how do you rename a file?

Share this post


Link to post
Share on other sites



how do you rename a file?

FileMove()

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

FileCopy() will also rename a file.

No, FileCopy() Copies a file.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Yes, it copies a file... and check this out... if the destination name is different, it will also rename it! So, if you want to preserve the original file, it can also come in handy. The difference is that FileMove() removes the original file. Understand, now?

(sp)

Edited by xcal

Share this post


Link to post
Share on other sites

^

To be technical..

that is NOT renaming.

You are renaming a completely different file. A copied version of that file. Not the same one..

Yeah it can come in handy, but FileMove() would be the correct choice for renaming a file.

Unless you do,

FileCopy($src, $dest)

FileDelete($src)

:lmao:

lol

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Yes yes... technically. :lmao: But, I think technically FileMove() isn't just renaming the file when you are using it to rename (just a guess).

The reason I mentioned FileCopy() in the first place, is because the help file doesn't point out it will rename a file during the copy. So, you could end up with people doing FileCopy() to a temp dir and then FileMove() to just copy and rename a file. And it was somewhat related to the topic.

Edited by xcal

Share this post


Link to post
Share on other sites

Yes yes... technically. :lmao: But, I think technically FileMove() isn't just renaming the file when you are using it to rename (just a guess).

The reason I mentioned FileCopy() in the first place, is because the help file doesn't point out it will rename a file during the copy. So, you could end up with people doing FileCopy() to a temp dir and then FileMove() to just copy and rename a file. And it was somewhat related to the topic.

Ok, I can see where you might think that... The helpfile entry for FileCopy() is inaccurate, describing the dest parameter as:

"The destination path of the copied file(s)." while it should be "The destination path and/or filename of the copied file(s)."

Rest assured that FileMove() only renames a file when used as such. The only time a copy/delete is performed is when moving files across volumes.

AutoIt Source:

// Move or copy operation?
if (bMove == true)
{
    if (bDiffVol == false)
    {
    bRes = MoveFile(szTempPath, szExpandedDest);
    }
    else
    {
        // Do a copy then delete (simulated copy)
        if ( (bRes = CopyFile(szTempPath, szExpandedDest, FALSE)) != FALSE )
        bRes = DeleteFile(szTempPath);
    }
}

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0