F
flebber
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()
dir = 'C:\Users\RenshawFamily\maven\Music\Foo Fighters\Live At
Wembley Stadium'
# add files to array unless a directoy is found
myFiles = Array.new << File.split(dir) unless File.file?("")
# Todo when files process step into directory and redo.
myFiles.each do|file|
# remove leading numbers a "-"
file.replace(/dd\-/, '')
Fileutils.mv(myFile, file)
end
end
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()
dir = 'C:\Users\RenshawFamily\maven\Music\Foo Fighters\Live At
Wembley Stadium'
# add files to array unless a directoy is found
myFiles = Array.new << File.split(dir) unless File.file?("")
# Todo when files process step into directory and redo.
myFiles.each do|file|
# remove leading numbers a "-"
file.replace(/dd\-/, '')
Fileutils.mv(myFile, file)
end
end