Sign in to follow this  
Followers 0
microbious

Please help to isolate filename only

6 posts in this topic

#1 ·  Posted (edited)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("",400,100)
GUISetState(@SW_SHOW)
$spawnpoint= "BluePlayerStart"
$openfile = FileOpenDialog('', @WorkingDir & "","", 1 + 2)
$filename = StringFormat("%%10s = [%10s]\n",$openfile)
MsgBox (0,'',$filename)
$input = GUICtrlCreateInput ($filename,0,0,400,20)
$inputimage = GUICtrlCreateInput ("<Images:UI_FrontEnd_Art.GameTypes.DeathMatch>",0,20,400,20)
$button1 = GUICtrlCreateButton ("Create",0,60)

While 1
   $nMsg = GUIGetMsg()
   Switch $nMsg
    Case $button1
        
        $mapname = GUICtrlRead($input)
        $ininame = $mapname & '.ini'
        FileDelete ($mapname & '.ini')
        MsgBox (0,'',$mapname)
IniWrite ($ininame,$mapname & " UTUIDataProvider_MapInfo","MapName",$mapname)
IniWrite ($ininame,$mapname & " UTUIDataProvider_MapInfo","FriendlyName",$mapname)
IniWrite ($ininame,$mapname & " UTUIDataProvider_MapInfo","PreviewImageMarkup",$inputimage)
IniWrite ($ininame,$mapname & " UTUIDataProvider_MapInfo","Description","None")

IniWrite ($ininame,$mapname & " UTUIDataProvider_InvasionMapInfo","MonsterSpawnPoints",$spawnpoint)




       Case $GUI_EVENT_CLOSE
           Exit

   EndSwitch
WEnd

I dont know how to isolate file name from full path.

Also filename has extension as we know it and i need to remove that, then it will write correct filename as $filename $var into ini.

I tried looking into stringtoformat but its so confusing i dont know what to do.

All i need is to remove the path and file extension and only keep filename

Can you guys help ?

Thanks

Edited by Gettingsmarter

Share this post


Link to post
Share on other sites



I dont know how to isolate file name from full path.

Also filename has extension as we know it and i need to remove that, then it will write correct filename as $filename $var into ini.

I tried looking into stringtoformat but its so confusing i dont know what to do.

All i need is to remove the path and file extension and only keep filename

Can you guys help ?

Thanks

Look at _PathSplit() in the help file.

:)


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

#3 ·  Posted (edited)

I tried

Dim $szDrive, $szDir, $szFName, $szExt
$filename = _PathSplit($openfile, $szDrive, $szDir, $szFName, $szExt)
MsgBox (0,'',$filename)

buts its not working :)

I dont know how does this thing work and do i even need DIM and all its variables ?

???????

Thank u for help

Edited by Gettingsmarter

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Local, $sPath, $sFile = "", $aFile
$sPath = "C:\some\path\somefile.au3"
$aFile = StringRegExp($sFile, "^.*\\(.*)$", 1)
If NOT @Error Then $sFile = $aFile[0]
MsgBox (0,'',$sFile)

Edit

You could also do it this way

$sFile = "C:\some\path\somefile.au3"
$sFile = StringRegExpReplace($sFile, "^.*\\(.*)$", "$1")
MsgBox (0,'',$sFile)
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Help file says

_PathSplit returns an array

so i tried

Dim $szDrive, $szDir, $szFName, $szExt
$filename = _PathSplit($openfile, $szDrive, $szDir, $szFName, $szExt)
_ArrayDisplay ($filename,"")
$Filenamevalue = _ArrayToString($filename,'',3,3)

and it worked

Thanks for ur help guys

Share this post


Link to post
Share on other sites

Check the edit I made to my post while you were writing your last reply. It's plain and simple.


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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