Jump to content

Changing file names


 Share

Recommended Posts

I would like to change all the names of the files in a directory. They all look like this:

Imported m3u playlists - TBO - Zitno.m3u

Imported m3u playlists - StuBru.m3u

Imported m3u playlists - Best.m3u

I would like to remove the "Imported m3u playlists - " part of each file.

How can I do this easily?

thx

The more you learn, the less you know.

Link to comment
Share on other sites

#include <File.au3>
$PATH = FileSelectFolder("SELECT","")
$FILE = _FileListToArray($PATH,"*.m3u",1)
If IsArray($FILE) Then
ProgressOn("M3U Rename","Rename ...")
For $INDEX = 1 To $FILE[0]
    $NAME = StringReplace($FILE[$INDEX],"Imported m3u playlists -","")
    FileMove($PATH & "\" & $FILE[$INDEX],$PATH & "\" & $NAME)
    ProgressSet(Int($INDEX*100/$FILE[0]),$FILE[$INDEX])
    Sleep(1000)
Next
ProgressOff()
EndIf

When the words fail... music speaks.

Link to comment
Share on other sites

@gertsolo

$path = @ScriptDir
$s_String = 'Imported m3u playlists -'
$FFFF = FileFindFirstFile('*.m3u')

If $FFFF <> -1 Then
    While 1
        $FFNF = FileFindNextFile($FFFF)
        If @error Then ExitLoop
        If StringInStr($FFNF, $s_String) Then
            FileMove($path & '\' & $FFNF, $path & StringReplace($FFNF, $s_String, ''))
        EndIf
    WEnd
EndIf

Not tested.

Edit : ops...to late :)

Cheers, FireFox.

Edited by FireFox
Link to comment
Share on other sites

#include <File.au3>
$PATH = FileSelectFolder("SELECT","")
$FILE = _FileListToArray($PATH,"*.m3u",1)
If IsArray($FILE) Then
ProgressOn("M3U Rename","Rename ...")
For $INDEX = 1 To $FILE[0]
    $NAME = StringReplace($FILE[$INDEX],"Imported m3u playlists -","")
    FileMove($PATH & "\" & $FILE[$INDEX],$PATH & "\" & $NAME)
    ProgressSet(Int($INDEX*100/$FILE[0]),$FILE[$INDEX])
    Sleep(1000)
Next
ProgressOff()
EndIf

Brilliant, thx m8!

The more you learn, the less you know.

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...