Jump to content

Processing all files in a directory


Guest skiman_co
 Share

Recommended Posts

Guest skiman_co

I just got this and I need a way to loop through all the RTF files in a directory, open them in WordPad, save them and then exit.

:ph34r:

I have found looping and I got the script to work with one specific file. Have been banging my head searching for a way to process all the files in a directory.

Any help will be greatly appreciated.

Link to comment
Share on other sites

  • Developers

Hope this helps :ph34r:

; Shows the filenames of all files in the current directory, note that "." and ".." are returned.

$search = FileFindFirstFile("*.*") 

; Check if the search was successful

If $search = -1 Then

    MsgBox(0, "Error", "No files/directories matched the search pattern")

    Exit

EndIf

While 1

    $file = FileFindNextFile($search)

    If @error Then ExitLoop

   

    MsgBox(4096, "File:", $file)

WEnd

; Close the search handle

FileClose($search)

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

I was gonna fix this for the "." and ".." not to show, but since goto is now called "evil" how can I do this ?

While 1
:Tester
    $file = FileFindNextFile($search)
    If $file = "." Then goto Tester
    If $file = ".." Then goto Tester

:ph34r:

Edited by Toppy
Link to comment
Share on other sites

@ Toppy

Why not something like ...

While 1
   $file = FileFindNextFile($search)
   If $file <> "." AND $file <> ".." Then  ; <> = Not Equal
      If @error Then ExitLoop
      MsgBox(4096, "File:", $file)
   EndIf
WEnd

Have not tested this but should put you in the right direction.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...