Jump to content

add to a string with letters and numbers


 Share

Recommended Posts

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...