Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Renaming a file using a wild card 2

Status
Not open for further replies.

bazil2

Technical User
Feb 15, 2010
148
DE
(Elementary user)

Could anyone please assist me with the following ...

I would like to rename some files that end with the suffix '.content' to '.pdf' using a single command but I want to maintain the stem of the file name, hence:

'ABC.content' should change to 'ABC.pdf'
'123.content' should change to '123.pdf'

Best regards
 
Hey a basic one that even i can answer:

for i in *.content ; do mv $i `basename $i`.pdf ; done
 
Hi

Use the [tt]rename[/tt] utility. It is not a standard tool, but is frequently present on Linux systems. However it may come from two packages and those two have different syntax :
Code:
[gray]# rename from the util-linux package[/gray]
rename '.content' '.pdf' *.content

[gray]# rename from the perl package[/gray]
rename 's/\.content/.pdf/' *.content


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top