Project2501 Posted December 30, 2007 Posted December 30, 2007 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)
Pioneer5250 Posted December 30, 2007 Posted December 30, 2007 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
rasim Posted December 30, 2007 Posted December 30, 2007 (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 December 30, 2007 by rasim
Project2501 Posted December 30, 2007 Author Posted December 30, 2007 wow thanks a lot for the fast replies. I'll give it a shot when i get home.
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