Jump to content

Get folders within a folder and files within that.


Bi0haZarD
 Share

Recommended Posts

ok, makin a relatively small script that i'm gonna put up on www.aimutation.com.

what i'm trying to do is get my script to read a folder, then each folder within that folder and the files within each one of those folders lol.

i know kinda complicated trying to explain that. so hope this helps.

C:\Program Files\AIM\Logs\

Bi0haZarD2005\ = My Screename on AIM

Buddy1\*has 10 files, each named YYYY-MM-DD.html

Bud12Buddy2\*has 15 files, following same rule as above

autoitr0x0rz\ *has 30 files, same rules

imanewb\*has 3 files, same rules

yea.. that still kinda didn't make sence. lol.

so, i would want my script to read:

C:\Program Files\AIM\Logs\Bi0haZarD2005\Buddy1\*read all .html files, and save them here in the unix time here then delete the original file*

C:\Program Files\AIM\Logs\Bi0haZarD2005\Bud12Buddy2\*do same as above*

and so on...

now, where my script comes into play, is it reads the time/date that the .html file was modified then converts the filename into what aimutation reads which is unix/EPOCH time. (time in seconds from Jan 01, 1970)

with what i have now, you have to manually select each file, and save it. and hopefully with what info i get, i'll be able to make the user just select the main log folder (Bi0haZarD2005 in my example), and have it automatically read and resave without needing to do a single thing.

#include <Date.au3>

$file = FileOpenDialog("Log File", "C:\pathtologs\screenname\otherpersonsscreename\date-time.html", "HTML (*.html)")

$t =  FileGetTime($file)

If Not @error Then
    $yyyymmddhhmmss = $t[0] & "/" & $t[1] & "/" & $t[2] & " " & $t[3] & ":" & $t[4] & ":" & $t[5]
EndIf

$datecalc = _DateDiff('s', "1970/01/01 00:00:00", $yyyymmddhhmmss)

$save = FileSaveDialog("Save Converted", "C:\pathtologs\screenname\otherpersonsscreename\unixtime.htm", "HTM (*.htm)", 8,$datecalc & ".htm")
If Not @error Then
    FileCopy($file, $save)
    sleep(500)
    FileDelete($file)
EndIf
Edited by Bi0haZarD
Link to comment
Share on other sites

You could write a function that takes a directory as a parameter and returns a list of files -- it would use FileFindFirstFile() and FileFindNextFile() to build the list of files residing in that folder and for any directory it finds, it would call itself passing that directory as a parameter and add that result to its own result.

Reading output from a DOS dir /b /s > temp.txt call however would be much quicker and easier to use, and faster to run.

Link to comment
Share on other sites

If you want to get fancy, you could also create an invisible GUI and use the DlgDirList DllCall - tho I agree w/ the previous poster that dir /b would likely be the fastest method to code. make sure you properly

handle longfilenames.

pseudocode
run dir /b /s to tempfile
read tempfile into an array ($a); packaged udf to do this in the include files
del tempfile
for each array element
  if filename not a directory then dostuff ;filegetattrib() call w/ stringinstr for "D" flag.
next

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

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