How do rename a file with multiple extensions
I have several files in a particular folder with multiple extensions which I want rename to a single exntension.
Ex: Original file abc.ev.stfm.org has to be renamed as abc.stfm All the files in the current folder has be to renamed to this particular extension. |
If all files in the folder have one multi-extension (i.e. all files match this - *.extensions...) then you could use 'basename'.
If not - try using awk or sed to split file name by '.' and take first result. Or youcould tryusing internal field separator (IFS) in bash or 'tr' And where from should 'stfm' extension get in the resulting file name? Is it taken from original file name? |
Hi manjeshjk,
Quote:
|
Quote:
Code:
for f in *.* ; do Evo2. |
Quote:
i.e rename .extension_you_have .stfm *.extension_you_have will do the required task. |
Quote:
It's not working, but producing same file names & extensions again. Can you check it again? @manjeshjk:: Can you try this: Code:
for f in $(ls | gawk -F"." '{print $1}'); do mv $f.* $f.stfm; done |
Hi,
Quote:
Edit: Eh? You're not the OP: how are you testing this? Evo2. |
All times are GMT -5. The time now is 08:25 PM. |