I do not have programming experience and mostly use one-liner or sometimes more to get the job done. I am having problem to batch rename the files that do not match a particular pattern.
Sample file-names from directory:
Meeting_Packages.pdf 13_textfile0 19_textfile0 23_textfile0 29_textfile0 33_textfile1 45_textfile0 5_textfile3 Membership.pdf 13_textfile1 19_textfile1 23_textfile1 29_textfile1 34_textfile0 46_textfile0 6_textfile0 xyz2009.pdf 13_textfile2 19_textfile2 23_textfile2 29_textfile2 34_textfile1 47_textfile0 6_textfile1 meeting.ics
I want to rename the files e.g.
xyz2009.pdf to the file from where they came (input file). Actually it is output of
ripmime with mails as
xx_textfilex and others are attachments. I want to name attachments as the original input file
#!/bin/bash FILES=*.mime for f in $FILES do echo "Processing $f" #rip mails into attachments and text files also add a prefix to text files ripmime -i $f -d ~/test/ripmime --prefix #Remove white spaces from files rename 's/ /_/g' ~/test/ripmime/* #rename attachments as original input files rename 's/\[^0-9]/'$f/ ~/test/ripmime/* done
My problem is the last rename line where I try to filter files other than
xx_textfilex and rename. I tried different regular expressions but could not do that. I can select and rename the textfiles by:
rename 's/textfiles/'$f/ ~/test/ripmime/*
but I need the inverse of that and rename files other then textfiles.
How can I do this?