Sign in to follow this  
Followers 0
cookiemonster

Read folder name, then remove part of it

8 posts in this topic

Hi,

Ive got a folder called '123 - abc'

I need to read this folder name then remove anything after the first white space and leave this in a varible.

So it would end up as:

$Varible = "123"

Any ideas?

Share this post


Link to post
Share on other sites



quinnj09,

 

Any ideas?

Lots - but what have you tried that has not worked? And how do you determine the folder name initially? Selected from a list? Matched in a search? :huh:

M23


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

Same here, show us what code you've come up with so far, and we'll help fill in any missing gaps you may have.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Share this post


Link to post
Share on other sites

Sorry for the slow reply guys, had some progress, im taking the name from an input label, it then removes any letters, so it does what I wanted it to do... well at least it did until I cam across this issue:

label might have in it '1234 - dog' which is fine because this then gives be '1234' which then is changed to 'fix1234' however yesterday I had one which was '5678 - 100 monkey' so this should of turned out to be '5678' which is then changed to 'fix5678' however as im sure youve already guess I actually got '5678100' then 'fix5678100'

Now I cant split the string and say take the first four numbers, because its not always four, sometimes its only three, sometimes its as many as nine, I basically need it to chuck away everything after the first space, this would then leave me with just '5678' in the last example.

$projectnumber = GUICtrlRead($projectname)
$fix_id_value=StringRegExpReplace($fixnumber,"\D+","")
GUICtrlSetData($fix_id, "fix" & $fix_id_value)

Share this post


Link to post
Share on other sites

cookiemonster,

This SRER works for me:

Global $aList[3] = ["1234 - dog", "5678 - 100 monkey", "123456789 - 500 pig"]

For $i = 0 To 2
    $sRet = StringRegExpReplace($aList[$i], "(\d+)\s.*", "fix$1")
    ConsoleWrite($sRet & @CRLF)
Next
Decode:

(\d+)   ; Look for a series of digits and capture it
\s      ; Until we reach a space
.*      ; Followed by the rest of the line

fix$1   ; Return the captured group prefixed with fix
All clear? :)

 

M23


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

Would StringSplit($fixstring," ") perform the function you're looking for? The first element in the returned array would be your result.

Share this post


Link to post
Share on other sites

Melba23 that works great cheers!

LeppyR64, now I feel very stupid! I almost gave myself the answer talking about not being able to use split string, stupid me didnt think of getting it to split it at the first space.

Either way cheers to both of ya!!

Share this post


Link to post
Share on other sites

Either split it at the first space ..... or the dash and then remove all spaces from the end result using StringStripWS.

The beauty with the second method, is that it accounts for a circumstance where the space may be missing ... though I'm not sure whether that is at all possible, so may be entirely unnecessary.


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

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