Sign in to follow this  
Followers 0
JobEst

_FileRename () UDF

1 post in this topic

#1 ·  Posted (edited)

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-once
#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
        SetError(1,0,0)
    Else
  If $sExtName = "" Then
      Local $ext = StringSplit($sFullpath, "." ,1)

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

_FileRename.au3

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  
Followers 0