Sign in to follow this  
Followers 0
Project2501

Changing file names based on Creation date

4 posts in this topic

Is there anyway to rename a bunch of .avi's in a single directory according to their creation date (eg. 30122007.avi)?

I was thinking something like this:

FileMove("C:\*.avi", "C:\" & @MDAY & @MON & @YEAR & ".avi") but this will just rename them to the current date (and won't work due to multiple files the same name)

Share this post


Link to post
Share on other sites



Hope this helps to start you on your way!

#include <File.au3>

Dim $aFileList = _FileListToArray("AVI Directory", "*.avi")
Dim $sDateString, $sTime

For $x = 1 To $aFileList[0]
    $sTime = FileGetTime("AVI Directory\" & $aFileList[$x], 1)
    $sDateString = $sTime[2] & $sTime[1] & $sTime[0]
    FileMove("AVI Directory\" & $aFileList[$x],"AVI Directory\" & StringTrimRight($aFileList[$x],4) & " " & $sDateString & ".avi") 
Next

Exit

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hello!

Try this:

#include <File.au3>

Dim $Source = "C:\Video", $FileTime, $nName, $sim = 1, $ren = 0

Global $FileArray = _FileListToArray($Source, "*.avi", 1)

If Not IsArray($FileArray) Then
    MsgBox(16, "Error", "avi files not found in " & $Source & " folder")
    Exit
EndIf

For $i = 1 To $FileArray[0]
    $FileTime = FileGetTime($Source &"\"& $FileArray[$i], 1)
    $nName = $FileTime[2] & $FileTime[1] & $FileTime[0]
    $ren = FileMove($Source &"\"& $FileArray[$i], $Source &"\"& $nName & ".avi")
    If Not $ren Then
        While Not $ren
            $sim += 1
            $ren = FileMove($Source &"\"& $FileArray[$i], $Source &"\"& $nName & "_" & $sim & ".avi")
            Sleep(1)
        WEnd
        $sim = 0
    EndIf
Next
Edited by rasim

Share this post


Link to post
Share on other sites

wow thanks a lot for the fast replies. I'll give it a shot when i get home.

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  
Followers 0