Jump to content
Sign in to follow this  

_FileRename () UDF

Recommended Posts


Hi, Guys!

I am a newie and My English is not good ! so I want to say "sorry" to you~

Today I have maked a UDF for Renaming a file. But I think it is not very useful! ;)

#include <Process.au3>
; #FUNCTION# ================================================
; Name...........: _FileRename
; Description ...: Rename a file
; Syntax.........: _FileName($sFilePath,$sFileName,[$sExtName = ""])
; Parameters ....: $sFilePath - Fullpath of the file to be read
;                         $sFileName - a new filename to be given
;                        $sExtName  - [optional] The extension of a file to be specified
; Return values .: Success - Returns a 1.
;                  Failure - Returns a 0
;                 @Error  - 1 =  the specified file cannot be found .
; Author ........: JobEst <www.autoitx.com >
; Remarks .......: This function is not profect currently , and hope someone can continue to modify it.
; Related .......:
; Link ..........: Inspiration from <http://www.autoitx.com/thread-10110-1-1.html (Author: ≈※爖※≈)>
; Example .......: No
; ============================================================
Func _FileRename($sFullPath, $sFileName,$sExtName = "")
    If Not FileExists($sFullpath) Then
  If $sExtName = "" Then
      Local $ext = StringSplit($sFullpath, "." ,1)

   $sExt = $ext[($ext[0])]
   $sExt = $sExtName
            $result =  _RunDOS("ren """& $sFullPath &""" """& $sFileName &""""&"."&$sExt&"""")
   If $result = 0 And @error <> 0 Then
     Return 0
        Return 1


Edited by JobEst

do something best~

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  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.