norjms Posted December 4, 2009 Share Posted December 4, 2009 (edited) Ok I'm a bit dumb for the like of me I can't get this to work. I have a folder with around 500 avi files inside located @ScriptDir\Rip Source\ There are only avi files inside so I don't need to figure out the filetype prior to running the command I have Handbrake in a folder @ScriptDir\Bin\HandbrakeCLI\HandbrakeCLI.exe I want to run this command against every file inside the folder: Handbrake.exe -i @ScriptDir\Rip Source\"thenameofthefile" -o @ScriptDir\Temp\"thenameofthefile minus the .ext avi" -L -f mp4 --strict-anamorphic -e x264 -q 20 -a 1 -E faac -6 dpl2 -R 48 -B 160 -D 0.0 --subtitle 1 --subtitle-burn=1 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1 <------this is all a one line command switch Here is the code I have that I am at a loss on how to get it to work. #Include <File.au3> #Include <Array.au3> $root = @ScriptDir $NormalSwitch = -L -f mp4 --strict-anamorphic -e x264 -q 20 -a 1 -E faac -6 dpl2 -R 48 -B 160 -D 0.0 --subtitle 1 --subtitle-burn=1 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1 $FileList =_FileListToArray($root & "\Rip Source","*", 1) If @Error=1 Then MsgBox (0,"","No Files\Folders Found.") Exit EndIf _ArrayDisplay($FileList,"$FileList") For $i=1 To $FileList[0] RunWait(@ScriptDir & "\Bin\HandbrakeCLI\HanBrakeCLI.exe -i " & @ScriptDir & "\Rip Source\" & $FileList[$i] & " " & "-o " & @ScriptDir & "\temp\" & $FileList[$i]) Next Thanks for your help Edited December 4, 2009 by norjms Link to comment Share on other sites More sharing options...
water Posted December 4, 2009 Share Posted December 4, 2009 (edited) Change your script to: #Include <File.au3> #Include <Array.au3> $root = @ScriptDir & "\Rip Source\" $NormalSwitch = "-L -f mp4 --strict-anamorphic -e x264 -q 20 -a 1 -E faac -6 dpl2 -R 48 -B 160 -D 0.0 --subtitle 1 --subtitle-burn=1 -x ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 -v 1" $FileList =_FileListToArray($root, "*.*", 1) If @error>0 Then MsgBox (0,"","No Files\Folders Found. Error: " & @error) Exit EndIf _ArrayDisplay($FileList,"$FileList") For $i=1 To $FileList[0] RunWait(@ScriptDir & "\Bin\HandbrakeCLI\HanBrakeCLI.exe -i " & $root & $FileList[$i] & " " & '-o "' & @ScriptDir & "\temp\" & $FileList[$i] & '" ' & $NormalSwitch) Next Edited December 4, 2009 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
norjms Posted December 4, 2009 Author Share Posted December 4, 2009 I got what I wanted to do working, but I can't seem to get the error code right. #Include <File.au3> #Include <Array.au3> Global $Configure = (@ScriptDir & "\Configuration\Configure.ini") $EncodePreset = IniRead($Configure,"Encode Preset","Key","default") $CompletedExt = IniRead($Configure,"Encode Ext","Key","default") $RipSource = IniRead($Configure, "DVD Rip Output Path", "Key", "default") $TransCodePath = IniRead($Configure, "Transcode Path", "Key", "default") $FileList =_FileListToArray($RipSource, "*.*", 1) If @Error=1 Then MsgBox (0,"","There are no files in " & $RipSource & " " & "to proccess.") Exit EndIf For $i=1 To $FileList[0] $result = StringTrimRight($FileList[$i], 4) $myCommand = @ScriptDir&"\HandbrakeCLI\"&"HandBrakeCLI.exe -i " &'"'& $RipSource & "\" & $FileList[$i]&'" ' & '-o "' & $TransCodePath & "\" & $result & $CompletedExt&'" ' & "-preset " & '"' &$EncodePreset&'"' RunWait($myCommand) Next The error I get is: Line 1091 Error: Subscript used with non-Array variable What is the proper way to deal with this error? Link to comment Share on other sites More sharing options...
GEOSoft Posted December 4, 2009 Share Posted December 4, 2009 (edited) If IsArray($FileList) Then For $i=1 To $FileList[0] $result = StringTrimRight($FileList[$i], 4) $myCommand = @ScriptDir&"\HandbrakeCLI\"&"HandBrakeCLI.exe -i " &'"'& $RipSource & "\" & $FileList[$i]&'" ' & '-o "' & $TransCodePath & "\" & $result & $CompletedExt&'" ' & "-preset " & '"' &$EncodePreset&'"' RunWait($myCommand) Next EndIf Edit: You could also handle it in your existing code by moving the loop. #Include <File.au3> #Include <Array.au3> Global $Configure = (@ScriptDir & "\Configuration\Configure.ini") $EncodePreset = IniRead($Configure,"Encode Preset","Key","default") $CompletedExt = IniRead($Configure,"Encode Ext","Key","default") $RipSource = IniRead($Configure, "DVD Rip Output Path", "Key", "default") $TransCodePath = IniRead($Configure, "Transcode Path", "Key", "default") $FileList =_FileListToArray($RipSource, "*.*", 1) If @Error Then MsgBox (0,"","There are no files in " & $RipSource & " " & "to proccess.") Exit Else For $i=1 To $FileList[0] $result = StringTrimRight($FileList[$i], 4) $myCommand = @ScriptDir&"\HandbrakeCLI\"&"HandBrakeCLI.exe -i " &'"'& $RipSource & "\" & $FileList[$i]&'" ' & '-o "' & $TransCodePath & "\" & $result & $CompletedExt&'" ' & "-preset " & '"' &$EncodePreset&'"' RunWait($myCommand) Next EndIf Edited December 4, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 4, 2009 Share Posted December 4, 2009 (edited) @norjms: There is no array returned from _FileListToArray() if there is an error. You are only testing for @error = 1. What about @error = 4? A better test for failure would be: If @error Then MsgBox (16, "Error", "Error listing files or no matching files in " & $RipSource) Exit EndIf Edit: Posted before seeing GEOSoft's reply. Edited December 4, 2009 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GEOSoft Posted December 4, 2009 Share Posted December 4, 2009 There is no array returned from _FileListToArray() if there is an error. You are only testing for @error = 1. What about @error = 4? A better test for failure would be: If @error Then MsgBox (16, "Error", "Error listing files or no matching files in " & $RipSource) Exit EndIf Damn but you're fast today. I was just coming back to change that in my last bit of code. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" 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