bash - remove date from filename but keep the file extension -



bash - remove date from filename but keep the file extension -

i have files these in directory called current_dir:

my data-file 2014-10.txt info file201409.txt

and want

my data-file.txt info file.txt

here tried

rename 's/ *[0-9]{4}-?[0-9]{2}.*$//' current_dir/*.txt

but removed .txt extension well.

i'm quite new linux, help me?

rename replaces matched part removing .*$ regular look keeps .txt

rename 's/ *[0-9]{4}-?[0-9]{2}//' current_dir/*.txt

examples

$ rename -n 's/ *[0-9]{4}-?[0-9]{2}//' *.txt rename(data file201409.txt, info file.txt) rename(my data-file 2014-10.txt, data-file.txt)

bash rename

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -