LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 12-06-2006, 01:57 AM   #1
peter88
LQ Newbie
 
Registered: Nov 2006
Posts: 20

Rep: Reputation: 0
How to modify the names of files and replace characters with other characters or symb


Hi, Does anyone have a script which does the following please:

Say you have a directory with files some of which you wish to change their name because perhaps they contain unwanted symbols like ~ , e.g. ~200005_tom_Berry_8.jpg . Lets say I want to replace the ~ with x and _ with - --> x200005-tom-Berry-8.jpg .

Ideally I would like to run the script from CWD and apply it to all the sub-directories (or use the find..-exec )in that filesystem, and not only be able to change the names of files but any directory names which match the criteria, however so long as I can do it an individual dir that will be fine for now.

Any ideas welcome. TIA.
 
Old 12-06-2006, 02:30 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,386

Rep: Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963Reputation: 1963
for i in *.jpg
do
mv $i $(echo $i | tr '~' 'x' | tr '_' '-')
done
 
Old 12-10-2006, 03:05 AM   #3
peter88
LQ Newbie
 
Registered: Nov 2006
Posts: 20

Original Poster
Rep: Reputation: 0
Thanks a lot for your suggestion, I will try it
 
  


Reply


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
Replacing characters in file names? yuccabrevifolia Linux - Software 1 04-19-2006 01:31 PM
BIND9 reject characters in host names jlinkels Linux - Software 1 02-10-2006 10:00 AM
Can i limit new file names created to 8 characters with samba ? amitsharma_26 Linux - Networking 1 12-16-2005 05:42 AM
rename file names with " ? characters fishbonz Linux - Newbie 2 05-31-2005 11:20 AM
replace null characters in a file Philipp Programming 2 09-20-2001 02:29 PM


All times are GMT -5. The time now is 06:17 AM.

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