Sign in to follow this  
Followers 0
mespork

Help with Wildcards and Directories

8 posts in this topic

Hello,

I need help with checking to see if a directory exists. The problem is that the directory will change depending on the computer. Here is what I have

FileFindFirstFile($vartemp&"\_AI*.tmp")

However, it is still returning -1 even though there is a folder named _AIB361.tmp in the directory (%temp% on the machine which $vartemp is set to)

Thanks

David

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hello,

I need help with checking to see if a directory exists. The problem is that the directory will change depending on the computer. Here is what I have

FileFindFirstFile($vartemp&"\_AI*.tmp")

However, it is still returning -1 even though there is a folder named _AIB361.tmp in the directory (%temp% on the machine which $vartemp is set to)

Thanks

David

Post exactly how you set the value in $vartemp. You could put a debug point in there like this:
$sFilePath = $vartemp & "\_AI*.tmp"
MsgBox(64, "Debug", "$sFilePath = " & $sFilePath)
$hFinder = FileFindFirstFile($sFilePath)
If $hFinder = -1 Then
     MsgBox(16, "Error", "FileFindFirstFile() failed")
     Exit
EndIf

>_<

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

mespork,

First, welcome to the Autoit forums.

You need to use the FileExists function to determine whether your folder exists. FileFindFirstFile needs a full path and filename (which can include wildcards) to return a search handle for further exploitation - hardly surprising that it returns -1 in this case!. >_<

Of course, FileFindFirstFile might well come in handy if you want to search the level above for all the folders which meet the mask you have set (_AI*.tmp[/i1]) and you want to choose between them.

M23

PS. In the longer term, You might find that reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here.


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

mespork,

First, welcome to the Autoit forums.

You need to use the FileExists function to determine whether your folder exists. FileFindFirstFile needs a full path and filename (which can include wildcards) to return a search handle for further exploitation - hardly surprising that it returns -1 in this case!. >_<

Of course, FileFindFirstFile might well come in handy if you want to search the level above for all the folders which meet the mask you have set (_AI*.tmp[/i1]) and you want to choose between them.

M23

PS. In the longer term, You might find that reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here.

After working trough it a couple of times I have it now reconizing that there is a folder there. However, the folder is gone it is not starting the next program. Here is my program, it is a pretty simple one:

$vartemp = EnvGet("temp")
$search = FileFindFirstFile($vartemp&"\_AI*.tmp")

Run("\\cazapp01\Apps\Autodesk\32\2010\AdminImage\setup.exe /qb /I \\cazapp01\Apps\Autodesk\32\2010\AdminImage\AutoCad_Apple.ini /language en-us", "\\cazapp01\Apps\Autodesk\32\2010\AdminImage")
Do
    Sleep(50000)
    FileClose($search)
    $search = FileFindFirstFile($vartemp&"\_AI*.tmp")
    MsgBox(4096,"Search", $search)
 Until $search == -1

Run("\\cazapp01\Apps\Autodesk\32\2010\Architecture\AdminImage\setup.exe /qb /I \\cazapp01\Apps\Autodesk\32\2010\Architecture\AdminImage\Architecture_Apple.ini /language en-us", "\cazapp01\Apps\Autodesk\32\2010\AdminImage")
Do
    Sleep(50000)
    FileClose($search)
    $search = FileFindFirstFile($vartemp&"\_AI*.tmp")
    MsgBox(4096,"Search", $search)
 Until $search == -1

Run("\\cazapp01\Apps\Autodesk\32\2010\3DsMax\AdminImage\setup.exe /qb /I \\cazapp01\Apps\Autodesk\32\2010\3DsMax\AdminImage\3DsMax_Apple.ini", "\\cazapp01\Apps\Autodesk\32\2010\3DsMax\AdminImage")
Do
    FileClose($search)
    $search = FileFindFirstFile($vartemp&"\_AI*.tmp")
    MsgBox(4096,"Search", $search)
 Until $search == -1

I am just trying to make an install for our AutoCad suite.

David

Share this post


Link to post
Share on other sites

Is there anything I am missing with the run command, should I pass it to a command prompt?

David

Share this post


Link to post
Share on other sites

I would try dropping the working directory param


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

I would try dropping the working directory param

Good idea. I will try when I get to work.

David

Share this post


Link to post
Share on other sites

Getting rid of the working directory and it worked. Thank you!!!

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  
Followers 0