Vindicator209 Posted March 26, 2008 Posted March 26, 2008 (edited) I'm making a little program that takes numbers out of filenames (music files...) Problem is, (after quite some time of figuring out) the StringReplace I was using wasn't searching the string, rather just using my var as a start... heres a little bit of it: $NewName is a copy variable for the file($Files) name, so just pretend it is "005 My Song.mp3" for the time being $NewName = StringTrimRight($Files[$i],3) For $a = 0 to 9 $NewName = StringReplace($NewName,Number($a),"") Next Now, as i said earlier, instead of replacing the number, it replaces the whole string... how can I get it to delete the TEXT number? P.S. The Number() is there cause that was one of the things I tried..heh... Edited March 26, 2008 by MethodZero [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
Xenobiologist Posted March 26, 2008 Posted March 26, 2008 Hi, Global $str[3] = ['C:\Downloads\test\bla\hugo\004 test.mp3', '004 Summer of 69.mp3', 'My 12 Song.mp3'] For $i = 0 To UBound($str) - 1 ConsoleWrite(_replaceLeadingDigits($str[$i]) & @CRLF) Next Func _replaceLeadingDigits($path) If StringInStr($path, '\') Then Local $return Local $parts_A = StringSplit($path, '\') Local $changed = StringRegExpReplace($parts_A[$parts_A[0]], '\A[\d|\s]*', '') For $i = 1 To UBound($parts_A) - 2 $return &= $parts_A[$i] & '\' Next Return $return & $changed EndIf Return StringRegExpReplace($path, '\A[\d|\s]*', '') EndFunc ;==>_replaceLeadingDigits Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Vindicator209 Posted March 26, 2008 Author Posted March 26, 2008 Thanks, it works like a charm [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
Xenobiologist Posted March 26, 2008 Posted March 26, 2008 Thanks, it works like a charmWelcome, you understand it, so you can edit it if needed.Mega Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times
Vindicator209 Posted March 26, 2008 Author Posted March 26, 2008 Well truthfully I have never used StringRegExpReplace until now, so I was confused but hey, I guess I learned something new, thanks again. [center]"When you look at old, classic games like Snake, you often put it off because it's such a simple game, but it's only when you actually try and create your own unique game from scratch, do you finally appreciate those games."[/center][center]Don't ask for answers if you haven't TRIED yet![/center][center]Most answers can be answered in the help file! Use it![/center]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now