beserk1 Posted November 13, 2007 Share Posted November 13, 2007 (edited) Background info:Files I am working with...... z078_000.jpeg ... z078_033.jpeg z096_000.jpg ... z096_030.jpg ...Part of code that is acting up.$search_Page = FileFindFirstFile ( $stamp & _FrmtDgt ( $count_chap , $num ) & "*.*" )$stamp is just the prefix of the files, in this case, "z"_FrmtDgt( $normal, $digit ) is a recursive function that will add 0 before the $normal integer untill it reached the require $digitEx. _FrmtDgt( 78, 3 ) will return "078" and _FrmtDgt( 5, 6 ) will return "000005"Problem:I am trying to use FileFindFirstFile to scan for files that match a certain filter in a directory, in this case "z078_*", "z096_*" etc. However, when reaching to "z096_*", it studdenly went back to "z078_*". More specificly,096_000 > 078_008 096_001 > 078_009 096_002 > 078_007 098_000 > 078_018 098_001 > 078_019 098_002 > 078_016 098_003 > 078_017 098_004 > 078_014 098_005 > 078_015where the left side is what it suppose to pick up, the right side is what is actually picking up. I have absolutly no idea why is only acting up on "078" and "096" and "098". This script has been used for over 10,000 files, and it has been working fine, only until now is been acting up and I have no idea why.Can someone solve this mystery for me?? Edited November 13, 2007 by beserk1 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2007 Share Posted November 13, 2007 You are not showing the likely problem code. I suspect the problem is with your _FrmtDgt() function. Why didn't you just use StringFormat()? It could also be how you are using the search handle (you don't show any FileFindNextFile() calls). Anyway, insert a debug function to show you what's being used, like: $sTest = $stamp & _FrmtDgt($count_chap , $num) & "*.*" ConsoleWrite("Debug: $sTest = " & $sTest & @LF) $search_Page = FileFindFirstFile($sTest) ;... $sResult = FileFindNextFile($search_Page) ConsoleWrite("Debug: $sResult = " & $sResult & @LF) ;... 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...
beserk1 Posted November 13, 2007 Author Share Posted November 13, 2007 (edited) Haha, I didn't know what to include. It shouldn't be _FrmtDgt() function, since I have a debug function that is checking that out too. Here, let me include more. While 1 $count_page = 1 $search_Page = FileFindFirstFile ( $stamp & _FrmtDgt ( $count_chap , $num ) & "*.*" ) If @error Then ExitLoop If $search_Page = -1 Then ExitLoop While 1 $Page = FileFindNextFile ( $search_Page ) If @error Then ExitLoop $file_ext = StringRight ( $Page , 4 ) If $file_ext = ".jpg" Or $file_ext = ".png" Or $file_ext = ".jpeg" Or $file_ext = ".gif" Then $PageNew = _FrmtDgt( $count_chap , 4 ) & "_" & _FrmtDgt( $count_page , 3 ) & StringLower ( $file_ext ) $DirNew = $DirWorking & "\" & $FolderDone & "\" & $FolderComic & "\chap_" & _FrmtDgt( $count_chap , 4 ) FileCopy ( $Page , $DirNew & "\" & $PageNew , 8 ) $count_page += 1 EndIf ;My debug function If $count_chap = 96 Or $count_chap = 98 Then MsgBox ( 4096, "Test", $stamp & @CR & _FrmtDgt ( $count_chap , $num ) & @CR & $Page & @CR & $file_ext & @CR & $PageNew & @CR & $DirNew ) EndIf WEnd $count_chap += 1 WEnd And the output of the debug MsgBox is: $stamp = z _FrmtDgt ( $count_chap , $num ) = 096 $Page = z078_008.jpeg $file_ext = .jpeg $PageNew = 0096_001.jpeg $DirNew = C:\_\_comic\chap_0096 Edited November 13, 2007 by beserk1 Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 13, 2007 Share Posted November 13, 2007 $file_ext = StringRight ( $Page , 4 ) If $file_ext = ".jpg" Or $file_ext = ".png" Or $file_ext = ".jpeg" Or $file_ext = ".gif" Then $PageNew = _FrmtDgt( $count_chap , 4 ) & "_" & _FrmtDgt( $count_page , 3 ) & StringLower ( $file_ext ) $DirNew = $DirWorking & "\" & $FolderDone & "\" & $FolderComic & "\chap_" & _FrmtDgt( $count_chap , 4 ) FileCopy ( $Page , $DirNew & "\" & $PageNew , 8 ) $count_page += 1 EndIfoÝ÷ Ûú®¢×zYr¢èZ½æ©®åzh^æÞq«¬z«¨¶:^«¨¶+9r«iË^®Éè·®)àF(!·Mú=¨ã¥åÊÊç±µéìðØmçhµú+ky^¶×«{^ȨX¤z:`_¢¸ézáÉ¢p¢¹zÛ^«¢+Ø$$ÀÌØí¥±}áÐôMÑÉ¥¹I¥¡Ð ÀÌØíA°MÑÉ¥¹1¸ ÀÌØíA¤´MÑÉ¥¹%¹MÑÈ ÀÌØíA°ÅÕ½Ðì¸ÅÕ½Ðì°À°´Ä¤¬Ä¤ That will get the file extension, regardless of its length, for your compare. 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...
beserk1 Posted November 13, 2007 Author Share Posted November 13, 2007 Ah, damn! You are good, I thought I could've left out that part. =P Like you said, I did have problem with it. However I added a extra part to the If statment. (seem like my goal for not flooding the thread with wall of code has failed =P ) ... ElseIf $file_ext = "jpeg" Then $file_ext = ".jpeg" $PageNew = _FrmtDgt( $count_chap , 4 ) & "_" & _FrmtDgt( $count_page , 3 ) & StringLower ( $file_ext ) $DirNew = $DirWorking & "\" & $FolderDone & "\" & $FolderComic & "\chap_" & _FrmtDgt( $count_chap , 4 ) FileCopy ( $Page , $DirNew & "\" & $PageNew , 8 ) $count_page += 1 ... I dont think is the extentsion thats messing it up, if that were the case, the code I had post before will simply omit the jpeg extentsion. But thanks for that bit of code you have, I been wanting to find a way to use the "." to scan for extentsion, but never got around to it. Thanks! Link to comment Share on other sites More sharing options...
beserk1 Posted November 15, 2007 Author Share Posted November 15, 2007 I still couldn't get it fix, can someone take a stab at it?? Link to comment Share on other sites More sharing options...
PsaltyDS Posted November 15, 2007 Share Posted November 15, 2007 I still couldn't get it fix, can someone take a stab at it??Post a completely self-contained short reproducer script, with only as much code as is required to copy/paste into SciTE and hit F5 to see the issue. 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...
weaponx Posted November 15, 2007 Share Posted November 15, 2007 Why are you using this: _FrmtDgt( $count_chap , 4 ) When we have the builtin function: ;Will display 00001 $length = 5 MsgBox(0,"",StringFormat("%.0" & $length & "u", 1)) or just MsgBox(0,"",StringFormat("%.05u", 1)) 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