JobEst Posted April 30, 2012 Share Posted April 30, 2012 (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! expandcollapse popup#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 April 30, 2012 by JobEst do something best~ Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now