Sign in to follow this  
Followers 0
PantZ4

Get the extion of a file

7 posts in this topic

How to get the extion(spelling?) of a file?

Like

If $msg = $GUI_EVENT_CLOSE Or $msg = $exit Then ExitLoop
        If $msg = $selectfilebutton Then
            GUICtrlSetData($statusgroup,"Status: Select File to Optimize")
            GUISetState(@SW_DISABLE,$GuiWindow)
            $file = FileOpenDialog("Select File to Optimize",@WorkingDir,"All Compatible File Types (*.w3m;*.w3x;*.wts;*.j)|Warcraft 3 Maps (*.w3m;*.w3x)|JASS Scripts (*.j)|String Files (*.wts)|Text Files (*.txt)|All Files (*.*)",1)
            $CheckHasEnableBoolean = 0
            If $file = "" Then
                GUICtrlSetData($filenamelabel,"File: No file selected")
                GUICtrlSetTip($selectfilebutton,"Press this button to select the file to optimize")
                GUICtrlSetData($helplabel1,"Select the file to optimize: "&@LF&"Works with maps (.w3m and .w3x), JASS scripts and string files.")
            Else
                GUICtrlSetData($filenamelabel,"File: "&$file)
                GUICtrlSetTip($selectfilebutton,$file)
                GUICtrlSetData($helplabel1,"Go now to Script Optimization"&@LF&"Or press Select File button again to choose another file")
            EndIf
            GUICtrlSetData($statusgroup,"Status: Waiting...")
            GUISetState(@SW_ENABLE,$GuiWindow)
            GUISetState(@SW_HIDE,$GuiWindow)
            GUISetState(@SW_SHOW,$GuiWindow)
        EndIf

But it didn't work.

Thank you ;)

Share this post


Link to post
Share on other sites



How to get the extion(spelling?) of a file?

After this I want it to check what file it is. I have tryed:

If $file = "*.w3x" Then

But it didn't work.

at least two options....

1.) Preferred: _PathSplit() - see help file

2.) StringInStr($file,".w3x") - see help file

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

How about

If StringRight($file,3) = "w3x" Then


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

at least two options....

1.) Preferred: _PathSplit() - see help file

2.) StringInStr($file,".w3x") - see help file

Cheers

Kurt

How does the _PathSplit() works?

My code:

$TestPath = _PathSplit($file, $szDrive, $szDir, $szFName, $szExt)
                $TestPath[3] = $filename

And $filename retruns to ""

Helpfile:

Return Value

Returns an array with 5 elements where 0 = original path, 1 = drive, 2 = directory, 3 = filename, 4 = extension

But maybe I shall not say $TestPath[3] = $filename?

Share this post


Link to post
Share on other sites

How does the _PathSplit() works?

as shown in the help file sample...

#include <file.au3>

$filename = "C:\temp\test.w3x"
Dim $szDrive, $szDir, $szFName, $szExt
$SplittedPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

if ($szExt = ".w3x") then
   msgbox(0,"INFO", "HuHu ... found a magic W3X file...")
endif
oÝ÷ Ù«©mz¹Ú¶+Þjëh×6#include <file.au3>

$filename = "C:\temp\test.w3x"
Dim $szDrive, $szDir, $szFName, $szExt
$SplittedPath = _PathSplit($filename, $szDrive, $szDir, $szFName, $szExt)

if ($SplittedPath[4] = ".w3x") then
   msgbox(0,"INFO", "HuHu ... found a magic W3X file...")
endif

Cheers

Kurt


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Now it works

Thanks ;)

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