Jump to content
Sign in to follow this  
gertsolo

Changing file names

Recommended Posts

gertsolo

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.

Share this post


Link to post
Share on other sites
Andreik

#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

Share this post


Link to post
Share on other sites
FireFox

@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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites
gertsolo

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

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.