Sign in to follow this  
Followers 0
knotten2

Rename file in spesific directory

3 posts in this topic

It only works when script is present in the current directory.

I want to remove "Html" from the file name in the directory of "C:\Downloads\tull"....

The script can be runed from anywhere,but the files that I want to change is always in "C:\Downloads\tull"....

Help anyone :P

Dim $Plass = 'C:\Downloads\tull\'
$search = FileFindFirstFile ($Plass & '*.*') 

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $filenew = $file
    $fileNew = StringReplace($fileNew,".html","")
    If $file <> $filenew then FileMove($file,$filenew)
WEnd

; Close the search handle
FileClose($search)

Share this post


Link to post
Share on other sites



It only works when script is present in the current directory.

I want to remove "Html" from the file name in the directory of "C:\Downloads\tull"....

The script can be runed from anywhere,but the files that I want to change is always in "C:\Downloads\tull"....

Help anyone :P

Dim $Plass = 'C:\Downloads\tull\'
$search = FileFindFirstFile ($Plass & '*.*') 

; Check if the search was successful
If $search = -1 Then
    MsgBox(0, "Error", "No files/directories matched the search pattern")
    Exit
EndIf

While 1
    $file = FileFindNextFile($search) 
    If @error Then ExitLoop
    $filenew = $file
    $fileNew = StringReplace($fileNew,".html","")
    If $file <> $filenew then FileMove($file,$filenew)
WEnd

; Close the search handle
FileClose($search)

If $file <> $filenew then FileMove($Plass & "\" & $file,$Plass & "\" & $filenew)


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

If $file <> $filenew then FileMove($Plass & "\" & $file,$Plass & "\" & $filenew)

Thanks...I can see it now.... :P

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