madasraka Posted May 31, 2010 Share Posted May 31, 2010 (edited) Almost finished fixing previously released contribution to gaming community file compressor (thaks to some of you) i got stuck at one point.My app uses external executable by giving it commands.Commands include full paths to file names which will be compressed in the end.There are many files selected here.Problem with that external executable is that it can only process an unknown to me # of characters.I think is has 1001 character limit for batch processing i dont know, all i know is that i cant process this much at once and i need somehow to limit it to processing 10 at the time (just to be safe)Command which executes compression is as simple as:$UT2004FilesToCompress = FileRead (@ScriptDir & "\UT2004Command.txt") Run ($UT2004UCC & ' compress ' & $UT2004FilesToCompress)For example:UCC Compress "C:\Dir\File1.ttt" "C:\Dir\File2.ttt" "C:\Dir\File3.ttt" "and many more"Once RUN command is executed, loop will wait for it to finish.While 1 ;loop $UT2004Exist = ProcessExists ("UCC.exe") ;check for UCC.exe process If $UT2004Exist > "" And $UT2004IsPlaying = "No" Then ;if UCC.exe is running and $UT2004IsPlaying is "NO" then SoundPlay (@TempDir & '/ut200401.wav') ;play ut200401.wav Assign ("UT2004IsPlaying", "Yes") ;and change $UT2004IsPlaying "NO" to "YES" ElseIf $UT2004Exist > "" And $UT2004IsPlaying = "Yes" Then ContinueLoop ElseIf $UT2004Exist = "" And $UT2004IsPlaying = "Yes" Then ExitLoop ElseIf $UT2004Exist = "" And $UT2004IsPlaying = "NO" Then ExitLoop EndIf WEndWhich has something else to do with the sound function which plays sound while loop is active.Question:How would i go about separating 10 (at best) file to process each time instead of all of those from txt file ? Edited June 1, 2010 by madasraka Link to comment Share on other sites More sharing options...
BugFix Posted June 1, 2010 Share Posted June 1, 2010 I think all your files are in the same folder - is it? If yes: Load all files in an array and build an command-string for every 10 files. I think, i'ts better to use RunWait instead Run. Test this: #Include <File.au3> Local $exePath = '..\path\UCC.exe' Local $WorkingDir = '..\path\' ; UCC-Folder Local $sPath = '..\your_ttt_folder\' Local $aFile = _FileListToArray($sPath , "ttt" , 1) Local $sRun = $exePath & ' Compress ' Local $count = 0 For $i = 1 To $aFile[0] $sRun &= '"' & $sPath & $aFile[$i] & '" ' $count += 1 If $count = 10 Or $i = $aFile[0] Then RunWait($sRun, $WorkingDir) ; i think it's better to use RunWait $sRun = $exePath & ' Compress ' $count = 0 EndIf Next Best Regards BugFix Link to comment Share on other sites More sharing options...
madasraka Posted June 1, 2010 Author Share Posted June 1, 2010 No, files are from different folders and maybe from different hard drives as well. I do not use Runwait because i cannot stop the script till runwait ends due to music loop in the background which is optional while process exist. See i cant check for process existence if its in Runwait mode instead of run after which i can use loop to check if it runs or not as well as allowing other parameters and functions to take place. Thanks for an idea but i ended up just giving a user a warning about 1001 character when such is detected warning about possible (if not imminent) crash. Link to comment Share on other sites More sharing options...
omikron48 Posted June 2, 2010 Share Posted June 2, 2010 Since it appears you are using a text file to list the files you want compressed, why not just format the input file to contain one file path per line? All you need to do afterwards is just load the file contents into an array, then loop through it. You can build your 'Run' command string by appending an array item then checking if you have either reach a safety limit in string length, or a count limit of sorts. 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