ReFran Posted July 25, 2007 Posted July 25, 2007 "Can you explain this a little more: If you unsure of this use good old DOS XCopy.exe to save the files in front of optimize." In Window choose Start - > execute and type in cmd (Enter), then you get the black DOS/CMD box. Now type in: xcopy U:\myPDFs\*.pdf C:\Temp\myPDFs\*.* /s This copies all pdf files (and only PDFs) from U:\myPDFs to C:\Temp\myPDFs including subfolders, which are not empty. Not existing folders will be installed. Even so easy you can copy back. In AutoIT you can execute the cmd statement via the Run(..) statement (see Helpfile). br, Reinhard
ConstantineGeorgantzas Posted July 25, 2007 Author Posted July 25, 2007 "Can you explain this a little more: If you unsure of this use good old DOS XCopy.exe to save the files in front of optimize."In Window choose Start - > execute and type in cmd (Enter), then you get the black DOS/CMD box.Now type in:xcopy U:\myPDFs\*.pdf C:\Temp\myPDFs\*.* /sThis copies all pdf files (and only PDFs) from U:\myPDFs to C:\Temp\myPDFs including subfolders, which are not empty. Not existing folders will be installed. Even so easy you can copy back.In AutoIT you can execute the cmd statement via the Run(..) statement (see Helpfile).br, ReinhardAre you talking about a program in accessories called "Command Prompt?" I thought of this because opening this program also gives you a black command box. If so, when I copied and pasted the text you gave me I got "Invalid Drive Specification / 0 files copied."If I got this wrong then I think "In Window choose Start - > execute and type in cmd (Enter), then you get the black DOS/CMD box," was unclear.By the way, the company directory is under S, not U, but I tried "xcopy S:\myPDFs\*.pdf C:\Temp\myPDFs\*.* /s" anyway.
ConstantineGeorgantzas Posted July 25, 2007 Author Posted July 25, 2007 "Can you explain this a little more: If you unsure of this use good old DOS XCopy.exe to save the files in front of optimize."In Window choose Start - > execute and type in cmd (Enter), then you get the black DOS/CMD box.Now type in:xcopy U:\myPDFs\*.pdf C:\Temp\myPDFs\*.* /sThis copies all pdf files (and only PDFs) from U:\myPDFs to C:\Temp\myPDFs including subfolders, which are not empty. Not existing folders will be installed. Even so easy you can copy back.In AutoIT you can execute the cmd statement via the Run(..) statement (see Helpfile).br, ReinhardOne more thing: I don't want all the pdf files, just the ones that meet certain criteria: size, date modified, uncompressed, etc. How does the process change now?Thanks
ReFran Posted July 25, 2007 Posted July 25, 2007 One more thing: I don't want all the pdf files, just the ones that meet certain criteria: size, date modified, uncompressed, etc. How does the process change now?ThanksThe folder where you copy from (S:\myPdfs) must exists.To get help for xcopy type into the "Command prompt" - "xcopy /h".So you will see date modified is not a problem (switch: /D:M-T-J). If you need the size as critera you need a program and we are back to autoIT.If you need compressed/uncompressed as criteria I think it is better to solve it via organisation. Set or reset file attributes or even better organize your folder into compresssed/uncompressed - and then I would compress and optimize all.br, Reinhard
ConstantineGeorgantzas Posted July 25, 2007 Author Posted July 25, 2007 Which macro should I use to get files out of my company's directory. I've tried various macros, but as of yet have had no luck. I should use ShellExecute to open these files right?
james3mg Posted July 25, 2007 Posted July 25, 2007 Constantine, I don't know if you have an understanding of arrays at all, but I'm going to recommend a different way than everyone else has been leading you...feel free to just ignore me if I've missed something or you're too far along the path the way you've been trying to do it. First, background on arrays...Arrays are just a special variable that can hold many different values, independantly of each other. They look like a variable, but they have square brackets with a number after them. The number in the square brackets tells it which data in the array you want to access (arrays' elements [that is, each bit of data it stores] are always numberd sequentially, starting with 0 and counting up, not skipping any numbers). For instance: expandcollapse popupDim $VarXYZ; <-this is a variable $VarXYZ="some data"; <-now $VarXYZ holds the data "some data". For proof, look at the next line. MsgBox(0,"Test",$VarXYZ); <- see? This pops up a message box that says "some data", because you told it to display the value of $VarXYZ. ;now for an array Dim $VarABC[4]; <-this is an array...see the difference? ;Here, I've told it I want to array to hold four pieces of data independantly of each other. ;Now we need to set the pieces of data, since they're all blank initially. $VarABC[0]="the first piece of data" $VarABC[1]="Another bit of data" $VarABC[2]="number three, here!" $VarABC[3]="This is the last bit of data" ;note that there are now four pieces of data contained in the array $VarABC, ;but since it always starts numbering at 0, the last number that's indexed is 3. ;as an example of how to get one of those pieces of data out of the array, look at the next line MsgBox(0,"Another test",$VarABC[0]);<- This will pop up a message box that says "the first piece of data", because you told it to display the value of $VarABC[0], which we defined above. ;now, up to this point, arrays haven't looked any different than a variable, ;since the name of each element in the array could just be taken as a string, ;and they're all unique ($VarABC[0] is a slightly different string than $VarABC[1]). ;However, we haven't used the array to its strength - namely that a variable could be in the brackets - ;it doesn't have to be a literal number you type out, as long as the variable resolves to a ;number that is within the range of the array (in this case a number between 0 and 3). Dim $i=1;<- as demonstration, let's make the variable $i contain 1. MsgBox(0,"Third test",$VarABC[$i]);<-Notice I used a variable to tell it which part of the array I want ;Understand? Since $i resolves to 1, it's the same as writing $VarABC[1]. ;In this case, the message box said "Another bit of data" because $i=1 and $VarABC[1]="Another bit of data" ;This is most useful in loops, such as: For $i=0 To 3 MsgBox(0,"Loop test",$VarABC[$i]) Next ;this 'for' loop will start by assigning $i to equal 0, run everything in the loop ;(in this case, just the line with the MsgBox), then increment $i by 1 until $i equals 3, ;at which point it will run the loop with $i equaling 3, then exit the loop. ;So you should get four message boxes from these three lines, showing the ;contents of $VarABC. As a side note, UBound() is designed specifically for arrays ;(it returns the number of elements, which you must remember is one number ;higher than the index number of the last piece of data), so that the For line ;above is equivalent to the following: ;For $i=0 To UBound($VarABC)-1oÝ÷ ØÚ0¶Ê®×«²Ö§v)yû¥&«¬¬# .Û.¬¶ë"¦:GßÛWËS ëk+h~)ÝjYmê]}ø¥zÊ'Ê«r©j|·öÉÞ· +Úâ½áÞ謶ºw-Ü¢+"Ú2¢êìr¸©·*.v÷öØZ½ëhæþ»§¢»§uê쵩ݶ¬¥ªíjëh×6Func _FileListToArrayEx($sPath, $sFilter = '*.*', $iFlag = 0, $sExclude = '', $iRecurse = False) If Not FileExists($sPath) Then Return SetError(1, 1, '') If $sFilter = -1 Or $sFilter = Default Then $sFilter = '*.*' If $iFlag = -1 Or $iFlag = Default Then $iFlag = 0 If $sExclude = -1 Or $sExclude = Default Then $sExclude = '' Local $aBadChar[6] = ['\', '/', ':', '>', '<', '|'] For $iCC = 0 To 5 If StringInStr($sFilter, $aBadChar[$iCC]) Or _ StringInStr($sExclude, $aBadChar[$iCC]) Then Return SetError(2, 2, '') Next If StringStripWS($sFilter, 8) = '' Then Return SetError(2, 2, '') If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, '') If Not StringInStr($sFilter, ';') Then $sFilter &= ';' Local $aSplit = StringSplit(StringStripWS($sFilter, 8), ';'), $sRead For $iCC = 1 To $aSplit[0] If StringStripWS($aSplit[$iCC], 8) = '' Then ContinueLoop If StringLeft($aSplit[$iCC], 1) = '.' And _ UBound(StringSplit($aSplit[$iCC], '.')) - 2 = 1 Then $aSplit[$iCC] = '*' & $aSplit[$iCC] Local $iPid If Not $iRecurse Then $iPid = Run(@ComSpec & ' /c ' & 'dir "' & $sPath & '\' & $aSplit[$iCC] & '" /b /o-e /od', '', @SW_HIDE, 6) Else $iPid = Run(@Comspec & ' /c dir /b /s /a "' & $sPath & '\' & $aSplit[$iCC] & '"', '', @SW_HIDE, 6) EndIf While 1 $sRead &= StdoutRead($iPid) If @error Then ExitLoop WEnd Next If StringStripWS($sRead, 8) = '' Then Return SetError(4, 4, '') Local $aFSplit = StringSplit(StringTrimRight(StringStripCR($sRead), 1), @LF) Local $sHold For $iCC = 1 To $aFSplit[0] If $sExclude And StringLeft(StringTrimLeft($aFSplit[$iCC], StringInStr($aFSplit[$iCC], '\', 0, -1)), _ StringLen(StringReplace($sExclude, '*', ''))) = StringReplace($sExclude, '*', '') Then ContinueLoop Switch $iFlag Case 0 $sHold &= $aFSplit[$iCC] & Chr(1) Case 1 If StringInStr(FileGetAttrib($aFSplit[$iCC]), 'd') Then ContinueLoop $sHold &= $aFSplit[$iCC] & Chr(1) Case 2 If Not StringInStr(FileGetAttrib($aFSplit[$iCC]), 'd') Then ContinueLoop $sHold &= $aFSplit[$iCC] & Chr(1) EndSwitch Next If StringTrimRight($sHold, 1) Then Return StringSplit(StringTrimRight($sHold, 1), Chr(1)) Return SetError(4, 4, '') EndFuncoÝ÷ ØÚ0Êjxµ©b²ÚjYr¢êéu÷âë0ØmçèZ0x%wºÚ"µÍÌÍÑ[SÝWÑ[SÝÐ^Q^ ][ÝÕNÌLÉ][ÝË ÌÎNÊÌÎNË ÌÎNÉÌÎNËYJoÝ÷ ØÚ0Ó~W¥Ëb±©Ú®¶²jwr¢ç¶§ºfÞ®ßW¬ßÚZ¶,¶Þw@hºwtß¡bââ²Ôáz_n+bØZµû§rبץÈÂ~)^²Úwtæ§²z-q«±éìØ¯zØ^ßÝýæ§±Ú'ßÛ^ÅÉnuæ§Éø¥z̨¹ø§u©Ý¶®ç¦y©ìßÙh¢H§jYl¹·bç-¢¸²íêZ¶"½é÷ö)í+jÇÓÝ¢z0Ê¡j÷+-¡ö¥*.®_~)^²ØZ·*.q©å¢mº.¥Ø^~)^³¡h¬×±¶Z(¥È^rH§ZµëÞ¯*.Á©í~âËZÇWzÔ¢ÍꮢÕ4÷j®¢Ö¦§Mú)^+-Ó~¢Â¥v¯{*.¶¬7¨~Ø^rêëz{_W¬£*.r¥uø º·¨ºØÊ°j{m¢('¢·¢¶ç¢Ùbë(jëh×6For $i=1 To UBound($FileList)-1 If FileGetSize("U:\"&$FileList[$i]) > 5000 Then ;insert code here that you want to run on files larger than 5000 kb ;say for instance you have a function called CompressFile(), you might call it on the current file like: CompressFile($FileList[$i]) EndIf NextoÝ÷ Øay-«wöËay·¬·²~ò¢ëh~)ÝÊW¬²¥ØZ·lçíËh¸y«®*mÂ+a¶¤{+-®±©Ý¬yÉbrK2¢éÞyÛhiËnjYrr©ë,¶W¬ßpSZ)ÚÌ®Ú2¢êéëâ¢ë*¹ë-Òéeº×¢²Ø^n襶)ðk+h«§r©®+jfî´¥Á¬¬ºÇíý¢Ww÷²~âËZÇ¢V®ÈÓÝ¡Ë4÷kaËq´ývë¶¢YhÂ)à)Þjëh×6Run(@ComSpec & ' \c start "" "c:\docs\this.txt"',"",@SW_HIDE) If you decide you want to use this method and have problems, post here...I'll try to check in on this thread, or as I said, you can decide this is too much and ignore me, no hard feelings This was a very long explanation, so if you decide to go another way and someday run into arrays again, don't shrink back - I'm sure someone will be able to give a better explanation of arrays than I did! They're really not too hard. And welcome to AutoIt! "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
ConstantineGeorgantzas Posted July 26, 2007 Author Posted July 26, 2007 (edited) I took your advice and tried your approach. I copied and pasted the large function that I could not understand and then I used: $FileList=_FileListToArrayEx("U:\", '*.pdf', 0, '', True) Like you said. But then I used: MsgBox(0,"# Files in $FileList",UBound($FileList)) To see how many files the array stored and I got zero as an answer. So there must be a problem. I have thought about using arrays for a long time to store the locations of each file from the company directory. That way, after they were altered in a temp folder, I could more easily send them back from where they came from. However, I am having trouble coming up with something. I also want to use the following code, which I have been working on to do the compressing, with whatever else I create - if at all possible: expandcollapse popup;In this program, the search engine window has been replaced by a temp folder, for the safety of the files ;Hopefully, I will be able to program the transfer of the files to the temp myself WinActivate("temp");for this simple program, the user has already used the computer's search engine to list the particular pdfs in the "search results" window WinWaitActive("temp");this program works with the search results window rather than conduct the search itself ControlClick("","",1,"",1,12,27);opens the very first file in the list of files Send("{ENTER 2}") While 1 WinActivate("Adobe Acrobat Standard");Gets Adobe Acrobat 6.0 involved WinWaitActive("Adobe Acrobat Standard") If WinExists("Adobe Acrobat", "This file appears") Then;if the file is unalterable due to formating issues then close the file WinActivate("Adobe Acrobat", "This file appears");the following waiting functions are used to slow down the loop so that the computer does not crash during processing WinWaitActive("Adobe Acrobat", "This file appears") Send("{ENTER}") WinWaitClose("Adobe Acrobat", "This file appears") Send("!f {DOWN 4} {ENTER}") ;$PID = Send("{ENTER} !f {DOWN 4} {ENTER}");my original attempt to slow down the loop ;ProcessWaitClose("$PID");the real process to slow down is the compression, not the work of the send function Else;else: reduce file size, save, and close file Send("!f {DOWN 9} {ENTER 2}") WinWaitClose("Reduce File Size") Send("{ENTER}") WinWaitNotActive("Save As" ) Send("{Left} {Enter}") WinWaitClose("Save As") Send("!f {DOWN 5} {ENTER} !f {DOWN 4} {ENTER}") ;$PID = Send("!f {DOWN 9} {ENTER 3} {Left} {Enter} !f {DOWN 5} {ENTER} !f {DOWN 4} {ENTER}") ;ProcessWaitClose("$PID") EndIf WinActivate("temp") WinWaitActive("temp") Send("{DOWN}");selects the next file to be opened Send("{ENTER 2}") WEnd And thank you very much for your fresh perspective and for going into your archives of code to pull out that function. Edited July 26, 2007 by ConstantineGeorgantzas
ConstantineGeorgantzas Posted July 26, 2007 Author Posted July 26, 2007 (edited) The whole exercise sounds pretty easy. You could certainly automate all five of those steps in AutoIt. If you haven't done so yet, download the latest production version 3.2.4.9 of AutoIt, and the latest version of SciTE. Go straight to the help file for AutoIt and scan the whole thing to get a sense of it. Then do the simple tutorials included. Then copy and run the demo scripts with FileCopy(), WinExists(), WinActivate(), WinWait(), MouseClick(), and Send(). After doing all that, you'll have the basics down to start writing your script. When you get stuck, post the broken code here and you'll get plenty of help. P.S. When installing AutoIt and SciTE, always select the option to "Edit Script" on double-clicking a file. Much safer for starting out (mine stays that way now, and I wish it was the default). I am having some problems with my script; so far I have only focused on the compression issue. When I run my script things just happen to quickly: the computer begins compressing other files before it finishes compressing the ones before it. I just want it to go one at a time to prevent crashing. For this reason you see so many winwaits and such in the conditional. expandcollapse popup;In this program, the search engine window has been replaced by a temp folder, for the safety of the files ;Hopefully, I will be able to program the transfer of the files to the temp myself WinActivate("temp");for this simple program, the user has already used the computer's search engine to list the particular pdfs in the "search results" window WinWaitActive("temp");this program works with the search results window rather than conduct the search itself ControlClick("","",1,"",1,12,27);opens the very first file in the list of files Send("{ENTER 2}") While 1 WinActivate("Adobe Acrobat Standard");Gets Adobe Acrobat 6.0 involved WinWaitActive("Adobe Acrobat Standard") If WinExists("Adobe Acrobat", "This file appears") Then;if the file is unalterable due to formating issues then close the file WinActivate("Adobe Acrobat", "This file appears");the following waiting functions are used to slow down the loop so that the computer does not crash during processing WinWaitActive("Adobe Acrobat", "This file appears") Send("{ENTER}") WinWaitClose("Adobe Acrobat", "This file appears") Send("!f {DOWN 4} {ENTER}") ;$PID = Send("{ENTER} !f {DOWN 4} {ENTER}");my original attempt to slow down the loop ;ProcessWaitClose("$PID");the real process to slow down is the compression, not the work of the send function Else;else: reduce file size, save, and close file Send("!f {DOWN 9} {ENTER 2}") WinWaitClose("Reduce File Size") Send("{ENTER}") WinWaitNotActive("Save As" ) Send("{Left} {Enter}") WinWaitClose("Save As") Send("!f {DOWN 5} {ENTER} !f {DOWN 4} {ENTER}") ;$PID = Send("!f {DOWN 9} {ENTER 3} {Left} {Enter} !f {DOWN 5} {ENTER} !f {DOWN 4} {ENTER}") ;ProcessWaitClose("$PID") EndIf WinActivate("temp") WinWaitActive("temp") Send("{DOWN}");selects the next file to be opened Send("{ENTER 2}") WEnd Edited July 26, 2007 by ConstantineGeorgantzas
james3mg Posted July 26, 2007 Posted July 26, 2007 I took your advice and tried your approach. I copied and pasted the large function that I could not understand and then I used: $FileList=_FileListToArrayEx("U:\", '*.pdf', 0, '', True) Like you said. But then I used: MsgBox(0,"# Files in $FileList",UBound($FileList)) To see how many files the array stored and I got zero as an answer. So there must be a problem.Glad you're finding it a worthy approach. Nice adaptation of the concepts too...good to see you really understand it. I had written all that without testing a lick of it (bad helper), so I was afraid that maybe I'd mis-typed something. So I copied SmOke_N's function from my post into a blank script, then added the lines $MyArray=_FileListToArrayEx(@UserProfileDir,"*.au3",0,'',True) MsgBox(0,"# files in $MyArray",UBound($MyArray)) which are similar to yours, and ran it, and I got a message box popping up telling me it had 9 files. So it seems that everything is correctly scripted. Now I guess we need to troubleshoot your connection to your U:\ - are you sure that it's mapped on your computer? (I know it's a dumb question, but you've gotta start somewhere). Now, copy a few pdfs to your desktop, and have it check in @UserProfileDir instead of "U:\" to see if it finds any then. Let me know what you find. "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
GEOSoft Posted July 26, 2007 Posted July 26, 2007 Glad you're finding it a worthy approach. Nice adaptation of the concepts too...good to see you really understand it. I had written all that without testing a lick of it (bad helper), so I was afraid that maybe I'd mis-typed something. So I copied SmOke_N's function from my post into a blank script, then added the lines $MyArray=_FileListToArrayEx(@UserProfileDir,"*.au3",0,'',True) MsgBox(0,"# files in $MyArray",UBound($MyArray)) which are similar to yours, and ran it, and I got a message box popping up telling me it had 9 files. So it seems that everything is correctly scripted. Now I guess we need to troubleshoot your connection to your U:\ - are you sure that it's mapped on your computer? (I know it's a dumb question, but you've gotta start somewhere). Now, copy a few pdfs to your desktop, and have it check in @UserProfileDir instead of "U:\" to see if it finds any then. Let me know what you find.Are you sure that it showed the right count? Generally when using a Ubound it would be UBound($MyArray)-1 Because the first element is the element count. 9 files would be 9 elements then add 1 element for the count = 10 elements 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!"
james3mg Posted July 26, 2007 Posted July 26, 2007 Are you sure that it showed the right count? Generally when using a Ubound it would be UBound($MyArray)-1 Because the first element is the element count. 9 files would be 9 elements then add 1 element for the count = 10 elementsGood call GEOSoft...I forgot that $MyArray[0] is the count of file names. Did you get that, Constantine? That's not a universal truth of arrays (as my array explanation script shows...[0] is whatever you assign it to be), but rather is the way many functions that write arrays for you work...kind of an alternate, easier way of getting the same data as UBound(). In this case, SmOke_N designed the function so that your array would look something like: $MyArray[0]=3 $MyArray[1]=folder\test.pdf $MyArray[2]=another folder\test.pdf $MyArray[3]=another folder\test2.pdf So that UBound($MyArray) would return 4 elements...but one of them ($MyArray[0]) isn't a file. So when using that _FileListToArrayEx() function, use $MyArray[0] to get a count, rather than UBound($MyArray), and in loops and the like, start your file list count at 1 instead of 0, OR just keep it in mind how your array is set up, and use UBound($MyArray)-1 as GEOSoft suggests, and still start your loops at count 1. "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
ConstantineGeorgantzas Posted July 27, 2007 Author Posted July 27, 2007 Good call GEOSoft...I forgot that $MyArray[0] is the count of file names. Did you get that, Constantine? That's not a universal truth of arrays (as my array explanation script shows...[0] is whatever you assign it to be), but rather is the way many functions that write arrays for you work...kind of an alternate, easier way of getting the same data as UBound(). In this case, SmOke_N designed the function so that your array would look something like: $MyArray[0]=3 $MyArray[1]=folder\test.pdf $MyArray[2]=another folder\test.pdf $MyArray[3]=another folder\test2.pdf So that UBound($MyArray) would return 4 elements...but one of them ($MyArray[0]) isn't a file. So when using that _FileListToArrayEx() function, use $MyArray[0] to get a count, rather than UBound($MyArray), and in loops and the like, start your file list count at 1 instead of 0, OR just keep it in mind how your array is set up, and use UBound($MyArray)-1 as GEOSoft suggests, and still start your loops at count 1. So basically UBound($MyArray)-1 gives me the true number of files - as opposed to UBound($MyArray) that gives me one extra file because the first element in $MyArray is my $MyArray[0]?
james3mg Posted July 27, 2007 Posted July 27, 2007 So basically UBound($MyArray)-1 gives me the true number of files - as opposed to UBound($MyArray) that gives me one extra file because the first element in $MyArray is my $MyArray[0]?You got it. And the data in $MyArray[0] is the same number as UBound($MyArray)-1. Ever see if that script works on a local directory, or why it didn't work on your U:\ ? "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
ConstantineGeorgantzas Posted July 27, 2007 Author Posted July 27, 2007 (edited) So basically UBound($MyArray)-1 gives me the true number of files - as opposed to UBound($MyArray) that gives me one extra file because the first element in $MyArray is my $MyArray[0]? Ah, I understand now. I read the help menu for _FileListToArray and saw: The array returned is one-dimensional and is made up as follows: $array[0] = Number of Files\Folders returned $array[1] = 1st File\Folder $array[2] = 2nd File\Folder $array[3] = 3rd File\Folder $array[n] = nth File\Folder So $array[4] has only 3 folders because $array[0]= Number of Files\Folders returned. However, UBound($MyArray) = 4 because it just gives the dimensions of the array - in our case 4 - and not the stuff that's in them that you care about. Therefore, I should use UBound($MyArray)-1 to know how many files I have in $MyArray. I hope this interpretation is the correct one. Edited July 27, 2007 by ConstantineGeorgantzas
GEOSoft Posted July 27, 2007 Posted July 27, 2007 Ah, I understand now. I read the help menu for _FileListToArray and saw: The array returned is one-dimensional and is made up as follows: $array[0] = Number of Files\Folders returned $array[1] = 1st File\Folder $array[2] = 2nd File\Folder $array[3] = 3rd File\Folder $array[n] = nth File\Folder So $array[4] has only 3 folders because $array[0]= Number of Files\Folders returned. However, UBound($MyArray) = 4 because it just gives the dimensions of the array - in our case 4 - and not the stuff that's in them that you care about. Therefore, I should use UBound($MyArray)-1 to know how many files I have in $MyArray. I hope this interpretation is the correct one.You got it! 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!"
ConstantineGeorgantzas Posted July 27, 2007 Author Posted July 27, 2007 Ever see if that script works on a local directory, or why it didn't work on your U:\ ?Yeah the script works; I got 918 as an answer.However, I am not sure what "U:\" means. I am normally a mac user, so I have never seen these things. The company directory from which I am supposed to get my files from is called "Group on 'Ny_fs1\Corp'". I am not sure if this changes anything, but what I know is that there are tens of thousands of pdf files in that directory; 918 seems too small a number - it seems like the number I would get after I have done all the filtering I need to do in the search such as for file size and whether or not a file has been compressed before.
james3mg Posted July 27, 2007 Posted July 27, 2007 (edited) I hope this interpretation is the correct one.Perfectly so, though most perfer to use $MyArray[0] rather than UBound($MyArray)-1. Either way gives you the same number. Be sure to use _FileListToArrayEx rather than _FileListToArray for your purposes however, because the function you found in the help file, while similar, does not search subfolders. _FileListToArrayEx is not included with the standard AutoIt #include package (yet), but the bit of code I had you copy into your script is what defines that function for your use in your script. Edit: oops...GEOSoft beat me to it Edited July 27, 2007 by james3mg "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
james3mg Posted July 27, 2007 Posted July 27, 2007 Yeah the script works; I got 918 as an answer. However, I am not sure what "U:\" means. I am normally a mac user, so I have never seen these things. The company directory from which I am supposed to get my files from is called "Group on 'Ny_fs1\Corp'". I am not sure if this changes anything, but what I know is that there are tens of thousands of pdf files in that directory; 918 seems too small a number - it seems like the number I would get after I have done all the filtering I need to do in the search such as for file size and whether or not a file has been compressed before.You'll probably want to use the path "\\Ny_fs1\Corp\Group" then. Try that and see if it gives you any more files. Also, to see what files it DID return, you can add this to the end of your script: FileDelete(@ScriptDir&"\filesfound.txt") For $i=1 To $MyArray[0] FileWriteLine(@ScriptDir&"\filesfound.txt",$MyArray[$i]) Next Run(@ComSpec & ' /c start "" "'&@ScriptDir&'\filesfound.txt"', "", @SW_HIDE) Now examine that list and see what (if anything) is missing. (I know that's not a trivial task, with thousands of possible file names...look at the paths and see if anything was blatently skipped). "There are 10 types of people in this world - those who can read binary, and those who can't.""We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true." ~Robert Wilensky0101101 1001010 1100001 1101101 1100101 1110011 0110011 1001101 10001110000101 0000111 0001000 0001110 0001101 0010010 1010110 0100001 1101110
GEOSoft Posted July 27, 2007 Posted July 27, 2007 (edited) Just a thought here. What would happen if all the files were copied to a folder then the whole folder compressed (easy) and then the files copied back? I THINK that the files should remain compressed and not require the PDF compression at all. It would take some experimenting to prove though. Edited July 27, 2007 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!"
ConstantineGeorgantzas Posted July 27, 2007 Author Posted July 27, 2007 (edited) You'll probably want to use the path "\\Ny_fs1\Corp\Group" then. Try that and see if it gives you any more files. When I used "\\Ny_fs1\Corp\Group" message box would not even give me a reply. By the way, what thinking led you to choose "\\Ny_fs1\Corp\Group" as the path as opposed to "Group on 'Ny_fs1\Corp'" or the "@UserProfileDir" that you used before. I am having trouble using logical reasoning to choose the path to anything anywhere. The code you gave me did let me see the files though. FileDelete(@ScriptDir&"\filesfound.txt") For $i=1 To $MyArray[0] FileWriteLine(@ScriptDir&"\filesfound.txt",$MyArray[$i]) Next Run(@ComSpec & ' /c start "" "'&@ScriptDir&'\filesfound.txt"', "", @SW_HIDE) I kept the @UserProfileDir to test it. Edited July 27, 2007 by ConstantineGeorgantzas
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