Jump to content
Sign in to follow this  
4Bravo

_FileListToArray And FileFindNextFile

Recommended Posts

4Bravo

I apologize if this is fairly simple, I've spend more hours than I want to on it and can't seem to get Autoit to work on every file in a subdirectory.

I've tried _FileListToArray and _FileListToArrayex but my complete lack of programming knowledge and copy and paste programming has only gotten me frustrated.

I am able to run the following script on 1 directory and all file sin the directory:

While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
;c:\tmp in the following line can be edited to your choice of file location
Run("C:\Program Files (x86)\Adobe\Adobe Flash CS5.5\flash.exe $sAutoItDir\" & $file)
$file = StringTrimRight($file, 4)
WinWaitActive($file)
; send export command
Send("^m")
WinWaitActive("Export Movie")
; set new filepath and name
Send("C:\tmp\" & $file & ".Mov")
Send("{ENTER}")
WinWaitActive("QuickTime Export Settings")
; dismiss export settings
Send("{ENTER}")
WinWaitActive("Adobe Flash CS5.5")
; dismiss export settings dialg
Send("{ENTER}")
; if you're not using MX 2004 Pro, edit the following line to match the Window title of your version
WinWaitActive($file)
; close .fla file
Send("^!x")
;Send("n")
WEnd
; Close the search handle
FileClose($search)

But when I tried to run that on subdirectories I couldn't seem to search the array:

#include <File.au3>
#include <Array.au3>
#include "FileListTOArrayEx.au3"
$sAutoItDir = "D:\Animations\CYOA\Animation\Stock_Animations\Boy\Talking"

$aArray = _FileListToArrayEx($sAutoItDir, "*.fla", 0 + 8 + 4)
$search = FileFindFirstFile($aArray)
While 1
$file = FileFindNextFile($search)
If @error Then ExitLoop
Run("C:\Program Files (x86)\Adobe\Adobe Flash CS5.5\flash.exe $sAutoItDir\" & $file)
$file = StringTrimRight($file, 4)
WinWaitActive($file)
; send export command
Send("^m")
WinWaitActive("Export Movie")
[b]; set filepath to open file's directory and name
Send("C:\tmp\" & $file & ".Mov")[/b]
Send("{ENTER}")
WinWaitActive("QuickTime Export Settings")
; dismiss export settings dialg
Send("{ENTER}")
WinWaitActive("Adobe Flash CS5.5")
; dismiss export settings dialg
Send("{ENTER}")
; if you're not using MX 2004 Pro, edit the following line to match the Window title of your version
WinWaitActive($file)
; close .fla file
Send("^!x")
;Send("n")
WEnd
; Close the search handle
FileClose($search)

I've also highlighted in bold my problem with using subdirectories, I'm not sure how to tell the mov to be rendered out the folder the file came from, in javascript I've used thelastIndexOf function to trim the directory, I see the StringTrimRight function removed the extension from the $file, but because every filename will have a different length I knew I couldn't use the same function to set a filepath

Any help would be greatly appreciated

Share this post


Link to post
Share on other sites
saywell

Look at Melba23's - it's great, and will do what you want.

William

Edited by saywell

Share this post


Link to post
Share on other sites
4Bravo

Thank you for replying, I have tried the with similar results. and after trying this _FO_FileSearch it seems to be the same. I get a list of files that is show in _ArrayDisplay. But where do I go from there? I've tried FileFindNextFile and the script doesn't want to do anything, it doesn't even return errors

#include <Array.au3>
#Include <FileOperations.au3>
$sPath = "D:AnimationsCYOAAnimationStock_AnimationsBoyTalking"

$FileList = _FO_FileSearch($sPath,'*fla')
_ArrayDisplay($FileList)
While 1
$file = FileFindNextFile($FileList)
If @error Then ExitLoop
;c:tmp in the following line can be edited to your choice of file location
Run("C:Program Files (x86)AdobeAdobe Flash CS5.5flash.exe $sPath" & $file)
$file = StringTrimRight($file, 4)
WinWaitActive($file)
; send export command
Send("^m")
WinWaitActive("Export Movie")
; set new filepath and name
Send("C:tmp" & $file & ".Mov")
Send("{ENTER}")
WinWaitActive("QuickTime Export Settings")
; dismiss export settings dialg
Send("{ENTER}")
  WinWaitActive("Adobe Flash CS5.5")
; dismiss export settings dialg
Send("{ENTER}")
; if you're not using MX 2004 Pro, edit the following line to match the Window title of your version
WinWaitActive($file)
; close .fla file
Send("^!x")
;Send("n")
WEnd
; Close the search handle
FileClose($FileList)

Share this post


Link to post
Share on other sites
Melba23

4Bravo,

How about explaining in simple terms what it is you are trying to do? At the moment that code is so confused I am not at all sure. ;)

All I can tell you is that:

$FileList = _FO_FileSearch($sPath,'*fla')
_ArrayDisplay($FileList
While 1
$file = FileFindNextFile($FileList)
If @error Then ExitLoop

is most certainly NOT looping through the array! :)

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
4Bravo

I'm trying to perform a set of commands on every file in all subdirectories of a given path, one file a time. In the example above I'm using flash to export a quicktime, but I need it for a few other things as soon as I figure out how to attach the $file variable to any of the results I get from RecFilesListToArray or _FO_FileSearch

Share this post


Link to post
Share on other sites
Melba23

4Bravo,

OK, the following code should get you a list of all the files in the path folder and all subfolders - and then extract each one in turn for you to "do things with it:

#include <Array.au3>
#include <RecFileListToArray.au3>

$sPath = "Your_Path"
$sMask = "*.fla" ; We are only returning *.fla files

; The parameters are: Path, Mask, Files only, Recur)
$aList = _RecFileListToArray($sPath, $sMask, 1, 1)

; Show what we got
_ArrayDisplay($aList)

; Now loop through the array
For $i = 1 To $aList[0]

    MsgBox(0, "File", "Number in array: " & $i & @CRLF & @CRLF & "Full file path: " & $sPath & "" & $aList[$i])

Next

Does that do what you want? :huh:

M23


Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
AZJIO

#include <Array.au3>

#include <FileOperations.au3>

$sPath = "D:AnimationsCYOAAnimationStock_AnimationsBoyTalking"



$FileList = _FO_FileSearch($sPath, '*fla')

If @error Then Exit

; _ArrayDisplay($FileList)

For $i = 1 To $FileList[0]

    ;c:tmp in the following line can be edited to your choice of file location

    Run("C:Program Files (x86)AdobeAdobe Flash CS5.5flash.exe " & $FileList[$i])

    $FileList[$i] = StringTrimRight($FileList[$i], 4)

    WinWaitActive($FileList[$i])

    ; send export command

    Send("^m")

    WinWaitActive("Export Movie")

    ; set new filepath and name

    Send("C:tmp" & $FileList[$i] & ".Mov")

    Send("{ENTER}")

    WinWaitActive("QuickTime Export Settings")

    ; dismiss export settings dialg

    Send("{ENTER}")

    WinWaitActive("Adobe Flash CS5.5")

    ; dismiss export settings dialg

    Send("{ENTER}")

    ; if you're not using MX 2004 Pro, edit the following line to match the Window title of your version

    WinWaitActive($FileList[$i])

    ; close .fla file

    Send("^!x")

    ;Send("n")

WEnd

Edited by AZJIO

Share this post


Link to post
Share on other sites
4Bravo

Thank you, both of these are on the right track. Is there a way to trim $aList[$i] OR$FileList[$i] So it just has the file name in it and not the path from my dir to where it found the file? it's needed for the first WinWaitActive function $aList[$i]is opening the file just fine, but it is then waiting for /dir/dir/file.fla whenit should be looking for file, no extention

Share this post


Link to post
Share on other sites
4Bravo

got this to work

#include <Array.au3>
#include <FileOperations.au3>
#include <RecFileListToArray.au3>
Opt("WinWaitDelay", 200)
$sPath = "D:AnimationsCYOAAnimationStock_AnimationsBoyTalking"
$FileList = _FO_FileSearch($sPath, '*fla', True, 125, 1 )
$justFILE = _RecFileListToArray($sPath, "*.fla", 1, 1, 1, 0)
$flaDIR = _RecFileListToArray($sPath, "*.fla", 1, 1, 1, 2)
For $i = 1 To $justFILE[0]
$justFILE[$i] = StringTrimRight($justFILE[$i], 4)
next
For $i = 1 To $flaDIR[0]
$flaDIR[$i] = StringReplace($flaDIR[$i], $justFILE[$i] & ".fla", "")
next

; _ArrayDisplay($FileList)
For $i = 1 To $FileList[0]
Run("C:Program Files (x86)AdobeAdobe Flash CS5.5flash.exe " & $FileList[$i])
;MsgBox(0, "", $justFILE[$i])
WinWaitActive($justFILE[$i])
; send export command
Send("^m")
WinWaitActive("Export Movie")
; set new filepath and name
Send($flaDIR[$i] & $justFILE[$i] & ".Mov")
Send("{ENTER}")
WinWaitActive("QuickTime Export Settings")
; dismiss export settings dialg
Send("{ENTER}")
WinWaitActive("Adobe Flash CS5.5")
; dismiss export settings dialg
Send("{ENTER}")
; if you're not using MX 2004 Pro, edit the following line to match the Window title of your version
WinWaitActive($justFILE[$i])
; close .fla file
Send("^X")
Next

This exports an MOV file to the directory the file was opened from. I probably didn't need to use both array functions, but they work together in the end.

Edited by 4Bravo

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  

×