Jump to content

Recommended Posts

Posted

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.

Posted

#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

Posted (edited)

@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
Posted

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

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
×
×
  • Create New...