1

I have thousands of files in a directory and need to remove a word if exist but not effect other documents without the word "draft" :

Currently ELC.Deeds.to.be.update-2014.draft.xls Rename to ELC.Deeds.to.be.updated-2014.xls

Currently AMC.Tax.time.envelope.client.listing.2013.draft.xls to AMC.Tax.time.envelope.client.listing.2013.xls

Other files like: AMC.Tax.time.envelope.client.listing.2014.xls would not need changing

So I would like to keep the file name and the extension just remove the word draft from any files that contain the word in the file name.

Any assistance would be great thanks.

1 Answers1

0

The syntax of rename (basically) is pretty simple:

rename perlexpr filemask

You can use such perlexpr to perform your task:

s/draft\\.//

Notice that backslashes are for escaping dot, since it means any symbol when not escaped. Normal slashes define empty string. Syntax of this trivial perlexpr is s/fromstr/tostr/.

Danatela
  • 13,243
  • 11
  • 45
  • 72