Jump to content
Sign in to follow this  
Guest skiman_co

Processing all files in a directory

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.

Share this post


Link to post
Share on other sites
Jos

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)


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Toppy

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

Share this post


Link to post
Share on other sites
magicboy

@ 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.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.