ChristiaanT Posted August 26, 2009 Share Posted August 26, 2009 Hello, I've read several topics on this forum, but I can't find a solution so far. I've got an application creating PDF's from my jpeg files. First I count the files using DirGetSize, but after that I want to loop through the files using FileFindFirstFile and FileFindNextFile. Now comes the problem: I've got many filenames starting with a square bracket (i.e. "[my_categorie]myfilename.jpg"). I came to the solution these functions don't read these files. When I put an alphabetical character as first character in the filename, it works well. Does anyone has a solution to this problem? Thanks in advance! Link to comment Share on other sites More sharing options...
jvanegmond Posted August 26, 2009 Share Posted August 26, 2009 I can't say this for sure without testing, but what happens if you change the filter to *. Does it pick up on the files with brackets? github.com/jvanegmond Link to comment Share on other sites More sharing options...
Andreik Posted August 26, 2009 Share Posted August 26, 2009 (edited) You can use also _FileListToArray() instead of FileFindFirstFile() and FileFindNextFile(), and work well with this kind of filenames. #include <File.au3> #include <Array.au3> $DIR = FileSelectFolder("Select","") If Not @error Then $FILE = _FileListToArray($DIR) _ArrayDisplay($FILE) EndIf Edited August 26, 2009 by Andreik When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 26, 2009 Moderators Share Posted August 26, 2009 ChristiaanT,FileFindFirstFile and FileFindNextFile work fine with [filenames] on my system. Could you post the code you are having problems with so we could take a look?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ChristiaanT Posted August 26, 2009 Author Share Posted August 26, 2009 Hmm, this is my code I'm using now: As you can see, I use "*" instead of "*.*" to disable filter at all, but with no results. Shows the filenames of all files in the current directory $filelist = FileFindFirstFile($cover_folder & "\*") ; Check if the search was successful If $filelist = -1 Then _ThrowError("Geen bestanden gevonden, probeer opnieuw a.u.b.", 1) Exit EndIf While 1 $file = FileFindNextFile($filelist) If @error Then ExitLoop To test I've got 4 jpegs in a the $cover_folder, named as following: [All]_my_cover.jpg [All]_my_cover_test.jpg Foo_bar_file_cover.jpg Test_cover.jpg The while loop wants to continue, but the $file var starts with Foo_bar_file_cover.jpg and ends with Test_cover.jpg. It completely ignores the first two. @Andreik, do I need to download the _FileListToArray() function? Or is it a build-in function? I don't see it in the documentation of AutoIt? Link to comment Share on other sites More sharing options...
GEOSoft Posted August 26, 2009 Share Posted August 26, 2009 You have to use #include<file.au3> at the top of your script In the help file look under User Defined Functions >> File Management 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...
Moderators Melba23 Posted August 26, 2009 Moderators Share Posted August 26, 2009 ChristiaanT,Here is the code I used in my file-finding script (which looks very much like yours) and it finds files renamed with the filenames you posted without problem!; Get search handle $hSearch = FileFindFirstFile($sCurrentPath & "*") ; $CurrentPath already ends in \ ; If folder empty move to next in list If $hSearch = -1 Then ContinueLoop ; Search folder While 1 $sName = FileFindNextFile($hSearch) ; Check for end of folder If @error Then ExitLoopAs to _FileListToArray, it is in the File.au3 include file and is covered in the full Help file. Use AutoIt3Help.exe to open the Help file and you get all the UDF Help as well.However, _FileListToArray, uses FileFindFirstFile and FileFindNextFile to work - I will be intrigued to see if it works for you! Could you post all of your script - perhaps there is something else which is causing a problem?M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
ChristiaanT Posted August 26, 2009 Author Share Posted August 26, 2009 Guys, I made it using the _FileListToArray function (very simple actually). I haven't got the time to spend much more time in it. I know this isn't solving the problem with the brackets in the functions, but maybe it's in my app then? I'll leave it for this... Thanks for the usefull suggestions/solutions! This is my first time using AutoIt, it works very handy I must say. I definetely gonna use it in future projects! Contact y'all then, maybe >_< Thanks! 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