Jump to content

Recommended Posts

Posted

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)

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...