Jump to content

Rename file in spesific directory


knotten2
 Share

Recommended Posts

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)
Link to comment
Share on other sites

  • Developers

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)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...