Changing txt

Hi all,

I currently use this code to delete text from file names when they are dropped in a folder.

find . -type f | while read i;do [ "$i" != "${i//2009abc/}" ] && mv "$i" "${i//2009abc/}" ;done

I have four versions of the code that delete the unwanted text if it has 2006, 2007, 2008 and 2009 with other standard text in it in four different folders.

Is there a way that I could re-write the code so that for argument sake delete any date from say 1990 to 2009 with and any date before that leave it in.

For example;

Input: name of file 2009 abc.mov
Output: name of file.mov
Input: name of file 2008 abc.mov
Output: name of file.mov
Input: name of file 2007 abc.mov
Output: name of file.mov
Input: name of file 2006 abc.mov
Output: name of file.mov
Input: name of file 1987 abc.mov
Output: name of file 1987.mov

Is this possible?

Thanks in advance :slight_smile:

Can anyone help me on this one?

Please be more patient, it's not allowed to bump up questions, read the rules.

Hi Monkey_dean,

Is it the file names which will have the dates like this ?

1987.abc.mov
2008.abc.mov
2009.abc.mov

or the content of the file will hav these data ?..

In the first case ... Is this file names are havng uniq syntax ( i mean date.abc.mov ) ?..always

or any where in the file name date hav to delete ?..

I think the best way to describe this and simplify the matter would be to say -

Can I edit this script:

find . -type f | while read i;do [ "$i" != "${i//abc/}" ] && mv "$i" "${i//abc/}" ;done

so that it will not only take out abc from the filename but also take out any numbers that are in the filename.

Sorry if I did not explain myself better.

Regards :slight_smile: