The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Korn: How to loop through a string character by character shew01 Shell Programming and Scripting 10 12-02-2008 07:58 AM
read a variable character by character, substitute characters with something else vipervenom25 UNIX for Dummies Questions & Answers 2 06-06-2008 04:18 PM
special character on Filename.. help!!!urgent genzbeat HP-UX 1 01-18-2008 03:55 PM
shortcut for tar cvf - [filename] | gzip > [filename].tar.gz bcamp1973 UNIX for Dummies Questions & Answers 4 12-11-2007 05:45 PM
rsync problem - space character in filename chief2 UNIX for Dummies Questions & Answers 3 09-24-2004 12:06 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-30-2007
xramm xramm is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
Filename character changes

I want to make a script for change filename's character not in English for a given directory. But I am not sure where am I starting from due to I am a little bit new user for scripts.
At least is there anybody can help me to make first step ,how can I find illegal or unwanted characters in file names and then maybe I have to make a conversion for example: from ı to i , from ö to o... like this..

Thanks a million.
  #2 (permalink)  
Old 05-30-2007
LiquidChild LiquidChild is offline
Registered User
  
 

Join Date: Jul 2005
Location: Belfast
Posts: 49
Quote:
Originally Posted by xramm
I want to make a script for change filename's character not in English for a given directory. But I am not sure where am I starting from due to I am a little bit new user for scripts.
At least is there anybody can help me to make first step ,how can I find illegal or unwanted characters in file names and then maybe I have to make a conversion for example: from ı to i , from ö to o... like this..

Thanks a million.
Surely the first place to start is to know what an illegal character is, do you have a finite list of them? And what you would want to convert them from and to? I think to do it for any given dictionary would be a massive job, could be wrong!
  #3 (permalink)  
Old 05-30-2007
xramm xramm is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
My list is limited for 10 characters, it is for characters those from Turkish to English, it is not a huge script nor a dictionary. Just want know a method to start; I have to use sed or awk or together ? like this , Thanks
  #4 (permalink)  
Old 05-30-2007
LiquidChild LiquidChild is offline
Registered User
  
 

Join Date: Jul 2005
Location: Belfast
Posts: 49
I am not an expert but would guess use the substitute function of awk to do this and just run your text through it replacing each of the 10 characters should they occur, have you tried that?
  #5 (permalink)  
Old 05-30-2007
aigles's Avatar
aigles aigles is offline Forum Advisor  
Registered User
  
 

Join Date: Apr 2004
Location: Bordeaux, France
Posts: 1,426
If one character is to be replaced by another character (just one), you can do something like that (the echo is for debug purpose):
Code:
#!/usr/bin/ksh
# ScriptFile: special_rename
from='àéêèïù'
  to='aeeeiu'
ls *[${from}]* |
while read filename
do
   echo mv ${filename} $(echo ${filename} | tr "$from" "$to")
done
Execution:
Code:
$ touch téléphone à_voir
$ special_rename
mv téléphone telephone
mv à_voir a_voir
$
Jean-Pierre.
  #6 (permalink)  
Old 05-30-2007
xramm xramm is offline
Registered User
  
 

Join Date: May 2007
Posts: 113
thanks

I ll try it and try it develop.Thank you.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0