S
S
Sargass2012-07-30 14:48:48
Perl
Sargass, 2012-07-30 14:48:48

How to remove multiple characters from a file name?

I process an array of files in a folder according to the name template. $_ =~ /ee/i;
The files have a name like sXXYYZZ_ee.XXX I add
the processed files to a subfolder, giving them my $filename = basename($work_file);exactly the same name. (if without basename, then it turns out a fun way instead of just a name)
So that's the actual question. Ideally, the files should be in the same folder, but all numerical matches, along with the extension, should remain, but the "_ee" at the end of the processed files can and should be removed.
How to remove these characters from the file name (these are always the last three characters before the extension, if anything) during processing, and save without them?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail Osher, 2012-07-30
@Sargass

s/_ee$/$filename/r
Isn't it?

S
Sargass, 2012-07-31
@Sargass

=~ s/^(.+)(_ee)(.+)$/$1$3/g
Wrong did a very simple thing - my before formatting.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question