gertsolo Posted February 2, 2009 Share Posted February 2, 2009 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 More sharing options...
Andreik Posted February 2, 2009 Share Posted February 2, 2009 #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 More sharing options...
FireFox Posted February 2, 2009 Share Posted February 2, 2009 (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 February 2, 2009 by FireFox Link to comment Share on other sites More sharing options...
gertsolo Posted February 2, 2009 Author Share Posted February 2, 2009 #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 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