Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-28-2011, 09:02 AM   #1
LQ Newbie
Registered: Jan 2011
Posts: 1

Rep: Reputation: 0
Unhappy How to remove dot from file name

I have an issue with file names i.e. A..png
I want rename these to normal A.png

Files are under directory to directory almost 300+ directories & inside
these dir. files are located. Can anyone tell me how to resolve this.
tried many commands, not working no change
Old 01-28-2011, 09:16 AM   #2
LQ Guru
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
You can try the find command to search for files recursively and apply a command using the -exec option, e.g.
find . -name \*..\* -exec rename "s/\.\././" '{}' +
The syntax of the rename command is that of debian/ubuntu systems, where rename is a perl script. For RedHat like systems the syntax is different, but based on the icon in your post, I assume you're running Ubuntu.

The statement above runs the rename command only once, with all the found files as arguments. If you get an 'argument list too long' error, change it to:
find . -name \*..\* -exec rename "s/\.\././" '{}' \;
that will run a rename command on one file at a time. Please, first try the rename command on a single file (without the find statement) to be sure it is the correct syntax for your system:
rename "s/\.\././" A..png
Old 01-28-2011, 09:20 AM   #3
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Generically, you use mv to rename files (move source filename to destination filename). To find all of the files of interest, you can use find. Algorithmically, you can change all instances of '..' to '.' in filenames. Putting all of that together into a bash script:
#! /bin/bash

for SOURCEFILE in $(find . -type f -name "*..png"); do
Try this out, running from the top level directory containing the files you want to rename. When you are satisfied that it does what you want, remove the echo from the last command in the loop, and then re-run it to do the actual renaming.

--- rod.


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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to remove all (dot) files without removing toplevel dir? mattengland Linux - Software 8 07-19-2011 02:57 PM
how to hide a file using file permissions in linux without using dot davender84 Linux - General 4 03-26-2009 12:13 AM
How to get file extension (without the dot) scls19fr Linux - General 11 08-21-2008 11:48 AM
Remove page advance when printing to a Oki ML 390 dot matrix OOsorio Linux - Newbie 0 05-19-2008 04:02 PM
useradd not accepting dot so i am not able to use dot in mail id hanu_raob Linux - General 5 05-13-2004 07:04 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:54 PM.

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