Sign in to follow this  
Followers 0
darklitch

add to a string with letters and numbers

2 posts in this topic

#1 ·  Posted (edited)

I have an array of filenames called $mpg

all my video files are name with MOVXXXXX.MPG where the x's are numbers. I would like to add 4000 to every number in the array then rename all the files with that new number. How can i do this? I am guessing split it into 3 different strings, beginning, middle, and end and add 4000 to the middle string?

Edited by darklitch

Share this post


Link to post
Share on other sites



You can do as you have sugested or you could use StringRegExpReplace. I can't test this code now so you will have to experiment a little to get it right.

Local $data = FilreRead(<datafile or other>)
Local $regexp = "MOV(\d+)\.MPG"
Local $replace = "MOV4000\1\.MPG" ;\1 is supposed to be replaced with the content of (\d+)
; You have to lookup $flags
; Not sure about the placements of the variables.
Local $res = StringRegExpReplace($data, $regexp, $replace, $flags)

Then you use FileMove to rename your files.

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