melf Posted July 18, 2009 Share Posted July 18, 2009 Hiya I just got a pretty good digital video camera but with the most crapiest software to dump the videos on my pc ( a gigantic 60meg of trash ) so i decided to make myself a simple autoit script to handle the job. My camera always hooks up as the h:/ drive and groups up videos by day folders..so basicly i just copy the SD_VIDEO folder from the camera to my pc and rename the .mod to .mpg ..all is working pretty good BUT my problem is the subfolders and files. the files always have the same name and i want my files to be renamed by date of creation to avoid overwrites. , thus far i wrote in all the subfolder names since i dont know how to copy a folder with all subfolders and rename the files : FileMove("h:\SD_VIDEO\PRG001" & "\*.mod", "e:\Movies\video" & "\*.mpg", 9) FileMove("h:\SD_VIDEO\PRG002" & "\*.mod", "e:\Movies\video" & "\*2.mpg", 9) FileMove("h:\SD_VIDEO\PRG003" & "\*.mod", "e:\Movies\video" & "\*3.mpg", 9) FileMove("h:\SD_VIDEO\PRG004" & "\*.mod", "e:\Movies\video" & "\*4.mpg", 9) FileMove("h:\SD_VIDEO\PRG005" & "\*.mod", "e:\Movies\video" & "\*5.mpg", 9) FileMove("h:\SD_VIDEO\PRG006" & "\*.mod", "e:\Movies\video" & "\*6.mpg", 9) FileMove("h:\SD_VIDEO\PRG007" & "\*.mod", "e:\Movies\video" & "\*7.mpg", 9) FileMove("h:\SD_VIDEO\PRG008" & "\*.mod", "e:\Movies\video" & "\*8.mpg", 9) FileMove("h:\SD_VIDEO\PRG009" & "\*.mod", "e:\Movies\video" & "\*9.mpg", 9) i know theres a _Date_Time_GetFileTime function but im a bit stuck on how to make it stick to rename each files (date of creation + .mpg ) any help would be greatly appreciated Link to comment Share on other sites More sharing options...
melf Posted July 18, 2009 Author Share Posted July 18, 2009 (edited) k so im thinking something along the line of $endname = ".mpg" $t = FileGetTime("h:\SD_VIDEO\PRG001" & "\*.mod", 1) $yyyymd = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] FileMove("h:\SD_VIDEO\PRG001" & "\*.mod", "e:\Movies\" & $yyyymd + $endname, 9) but how can i make it rename it BY file in the directory?( right now it only names 1 file ) and for some reason it wont add .mpg at the end.. Edited July 18, 2009 by melf Link to comment Share on other sites More sharing options...
melf Posted July 18, 2009 Author Share Posted July 18, 2009 k so now i fixed the renaming but it still only renames the first file and deletes the rest...is there a way to make it do subfolders as well? $t = FileGetTime("h:\SD_VIDEO\PRG001" & "\*.mod", 1) $yyyymd = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] FileMove("h:\SD_VIDEO\PRG001", "e:\Movies\Moment video\" & $yyyymd, 9) FileMove("e:\Movies\Moment video\", "e:\Movies\Moment video" & "\*.mpg", 9) Any feed back would be greatly appreciated Link to comment Share on other sites More sharing options...
Beege Posted July 19, 2009 Share Posted July 19, 2009 k so now i fixed the renaming but it still only renames the first file and deletes the rest...is there a way to make it do subfolders as well? $t = FileGetTime("h:\SD_VIDEO\PRG001" & "\*.mod", 1) $yyyymd = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] FileMove("h:\SD_VIDEO\PRG001", "e:\Movies\Moment video\" & $yyyymd, 9) FileMove("e:\Movies\Moment video\", "e:\Movies\Moment video" & "\*.mpg", 9) Any feed back would be greatly appreciated heres a couple things - $t = FileGetTime("h:\SD_VIDEO\PRG001" & "\*.mod", 1) is the same as $t = FileGetTime("h:\SD_VIDEO\PRG001\*.mod", 1) Another thing is that I dont think you should be using wildcards with filegettime function. That will make it only return the first file in your folder. Is this the actual code you are using? If not post your entire code. Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
melf Posted July 19, 2009 Author Share Posted July 19, 2009 yeah this is the actual code im using..basicly i just want it to rename all files in folder/subfolders to its date of creation .mpg Link to comment Share on other sites More sharing options...
Beege Posted July 19, 2009 Share Posted July 19, 2009 Try this - $List = _FileSearch('h:\SD_VIDEO', '*.mod') For $i = 1 to $List[0] $t = FileGetTime($List[$i], 1) $yyyymd = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & '.mpg' FileMove($List[$i], 'e:\Movies\Moment video\' & $yyyymd, 9) Next Func _FileSearch($s_Dir, $s_Mask = '*', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', $s_Dir, @SW_HIDE, 2+4) ProcessSetPriority($i_Pid, 5) While Not @error $s_Buf &= StdoutRead($i_Pid) WEnd $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) ProcessClose($i_Pid) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc ;==>_FileSearch Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
melf Posted July 19, 2009 Author Share Posted July 19, 2009 (edited) still creating just 1 mpg file and skipping all the rest Edited July 19, 2009 by melf Link to comment Share on other sites More sharing options...
Malkey Posted July 19, 2009 Share Posted July 19, 2009 still creating just 1 mpg file and skipping all the rest Maybe, all the mod files have the same creation date caused by copying or moving all the files in one operation. So that all the mpg files created are overwriting the previous mpg file with the same creation date name. Here is another attempt. expandcollapse popup; #include <File.au3> #include <Array.au3> #cs _FileMoveMod("h:\SD_VIDEO\PRG001", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG002", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG003", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG004", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG005", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG006", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG007", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG008", "\*.mod", "e:\Movies\video", "mpg", 9) _FileMoveMod("h:\SD_VIDEO\PRG009", "\*.mod", "e:\Movies\video", "mpg", 9) #ce ;This next test _FileMoveMod() will copy all txt files in script directory to BackUp1 directory ;with new name & file extension. The file creation dates will remain the same. _FileMoveMod(@ScriptDir & "\", '*.txt', @ScriptDir & "\BackUp1\", "mpg", 9) Func _FileMoveMod($sFilePathSource, $sSearchFileFilter, $sFilePathDest, $sDestFileExt, $flag = 8) If StringRight($sFilePathSource, 1) <> "\" Then $sFilePathSource &= "\" Local $aList = _FileListToArray($sFilePathSource, $sSearchFileFilter, 1) If IsArray($aList) Then ;_ArrayDisplay($aList,"$FileList") For $i = 1 To $aList[0] _FileTimeMove($sFilePathSource & $aList[$i], $sFilePathDest, $sDestFileExt, $flag) Next Else MsgBox(0, "", "No files found") EndIf Return EndFunc ;==>_FileMoveMod ; Retains original creation date after file moved. Func _FileTimeMove($sFilePathNameSource, $sPathDest, $sNewFileExt = "", $flag = 8) Local $sFilePathNameDest, $sSrcCreateTime = "" If $sNewFileExt = "" Then $sNewFileExt = StringRegExpReplace($sFilePathNameSource, "^.*\.", "") ;ConsoleWrite("$sNewFileExt " & $sNewFileExt & @CRLF) If StringRight($sPathDest, 1) <> "\" Then $sPathDest &= "\" $aArr = FileGetTime($sFilePathNameSource, 1); 1 = Created For $x = 0 To UBound($aArr) - 1 $sSrcCreateTime &= $aArr[$x] Next ; $sSrcCreateTime format is "YYYYMMDDHHMMSS" [See FileGetTime() help file.] $sFilePathNameDest = $sPathDest & "Z" & $sSrcCreateTime & "." & $sNewFileExt If FileExists($sFilePathNameDest) Then Local $iNum = 0 While 1 $iNum += 1 If FileExists($sPathDest & "Z" & $sSrcCreateTime & "_" & $iNum & "." & $sNewFileExt) = 0 Then $sFilePathNameDest = $sPathDest & "Z" & $sSrcCreateTime & "_" & $iNum & "." & $sNewFileExt ExitLoop EndIf WEnd EndIf ;*********** FOR TESTING USE FileCopy **************** FileCopy($sFilePathNameSource, $sFilePathNameDest, $flag); 8 = Create if it doesn't exist. ;FileMove($sFilePathNameSource, $sFilePathNameDest, $flag); 8 = Create if it doesn't exist. FileSetTime($sFilePathNameDest, $sSrcCreateTime, 1); 1 = Created time of file Return EndFunc ;==>_FileTimeMove ; Link to comment Share on other sites More sharing options...
melf Posted July 21, 2009 Author Share Posted July 21, 2009 same thing..even after i checked if the date was the same for each file Link to comment Share on other sites More sharing options...
Beege Posted July 21, 2009 Share Posted July 21, 2009 Try to verify some things I guess.. Make sure all files are being added to the array and all names are being change correctly. Here I added a _arraydisplay() and Msgbox(). #include<array.au3> $List = _FileSearch('h:\SD_VIDEO', '*.mod') _ArrayDisplay($List,'all mod files');----------------------- For $i = 1 to $List[0] $t = FileGetTime($List[$i], 1) $yyyymd = $t[0] & $t[1] & $t[2] & $t[3] & $t[4] & '.mpg' MsgBox(0,'file move', $List[$i] & ' to e:\Movies\Moment video\' & $yyyymd) FileMove($List[$i], 'e:\Movies\Moment video\' & $yyyymd, 9) Next Func _FileSearch($s_Dir, $s_Mask = '*', $i_Recurse = 1) Local $s_Command = ' /c dir /B "' If $i_Recurse = 1 Then $s_Command = ' /c dir /B /S "' Local $s_Buf = '', $i_Pid = Run(@ComSpec & $s_Command & $s_Mask & '"', $s_Dir, @SW_HIDE, 2+4) ProcessSetPriority($i_Pid, 5) While Not @error $s_Buf &= StdoutRead($i_Pid) WEnd $s_Buf = StringSplit(StringTrimRight($s_Buf, 2), @CRLF, 1) ProcessClose($i_Pid) If UBound($s_Buf) = 2 AND $s_Buf[1] = '' Then SetError(1) Return $s_Buf EndFunc ;==>_FileSearch Assembly Code: fasmg . fasm . BmpSearch . Au3 Syntax Highlighter . Bounce Multithreading Example . IDispatchASMUDFs: Explorer Frame . ITaskBarList . Scrolling Line Graph . Tray Icon Bar Graph . Explorer Listview . Wiimote . WinSnap . Flicker Free Labels . iTunesPrograms: Ftp Explorer . Snipster . Network Meter . Resistance Calculator Link to comment Share on other sites More sharing options...
melf Posted July 24, 2009 Author Share Posted July 24, 2009 found out the problem...my OS was dating them wrong..works like a charm now...ty very much is there a way to add a graphical loading bar for transfers between msgbox pop ups? 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