Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 12-15-2017, 03:04 AM   #1
LQ Newbie
Registered: Dec 2017
Posts: 2

Rep: Reputation: Disabled
How to RENAME files name with multiple dots (...)

Hello, recently I have discovered wonderful function like RENAME in Linux, I'm using it in script with function FIND to partly rename multiple files, for example:

find /srv/my_disk/ -type f -name '*.*' | rename 's/DVDRip/./'

after that change (and many others), new name have many dots in file name like:

Movie_Name ... 2010...avi

I wonder (because I can't do this in my way) how to remove any dot to nothing (delete all dots)?

I have tried:

find /srv/my_disk/ -type f -name '*.*' | rename '1,$s/\.\.//g'

but it doesn't work

any clue/idea?

ps. I don't wan to use any additional scripts, just use simple functions like FIND and RENAME

thanks in advance

Old 12-15-2017, 05:16 PM   #2
Registered: Dec 2011
Location: Simplicity
Posts: 601

Rep: Reputation: 280Reputation: 280Reputation: 280
Delete two or more consecutive dots
rename 's/\.{2,}//g'
rename 's/\.\.+//g'
Old 12-15-2017, 08:21 PM   #3
LQ Guru
Registered: Mar 2004
Distribution: Slackware
Posts: 5,687

Rep: Reputation: 510Reputation: 510Reputation: 510Reputation: 510Reputation: 510Reputation: 510
If you want to keep the last dot of file extension (.avi)
rename 's/\.{2,}(?![^.]+$)//g'
Old 12-15-2017, 08:44 PM   #4
Registered: Dec 2017
Location: _Austro_Bavaria_
Distribution: SLACKWARE 96 -> SUSE 6.2 & REDHAT -> Gentoo & ARCH-Linux & Linux-Mint
Posts: 290

Rep: Reputation: Disabled
i think sed can do it

I was as of now lazy to learn advanced bash techniques.
Old 12-17-2017, 07:57 AM   #5
LQ Newbie
Registered: Dec 2017
Posts: 2

Original Poster
Rep: Reputation: Disabled
THX 'MadeInGermany' - seams it works


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
bash - rename multiple files with dots in filename eldude543 Programming 20 05-21-2016 12:17 AM
[SOLVED] rename multiple files lghizoni Linux - Newbie 7 01-30-2013 09:48 AM
rename file names : replace dots by spaces, keep the extension Reda01 Programming 5 03-28-2011 09:54 AM
rename multiple files tjay1983 Programming 3 08-10-2010 01:43 AM
How to rename multiple files? Rostfrei Linux - Newbie 3 07-11-2006 07:06 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 09:37 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration