I think you mean file.replace(/\d\d\-/,'') rather than file.replace(/dd\-/,=
'')

/dd\-/ will only match the character 'd' twice followed by a '-'


On 9 May 2011 14:45, flebber <flebber.crue / gmail.com> wrote:
> I am new too using regex on files and I am not quite getting the
> result I expect. The script currently doesn't error but also doesn't
> update the file either.
>
> Trying to remove leading numbers and ' - 'from the start of a filename
> given a directory.
>
> require 'fileutils'
>
> def cleanFiles()
> =A0dir =3D 'C:\Users\RenshawFamily\maven\Music\Foo Fighters\Live At
> Wembley Stadium'
> =A0# add files to array unless a directoy is found
> =A0myFiles =3D Array.new << File.split(dir) unless File.file?("")
> =A0# Todo when files process step into directory and redo.
> =A0myFiles.each do|file|
> =A0 =A0# remove leading numbers a "-"
> =A0 =A0file.replace(/dd\-/, '')
> =A0 =A0Fileutils.mv(myFile, file)
> =A0end
> end
>
>