Filename character changes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filename character changes
# 1  
Old 05-30-2007
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. Smilie
# 2  
Old 05-30-2007
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. Smilie
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  
Old 05-30-2007
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  
Old 05-30-2007
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  
Old 05-30-2007
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  
Old 05-30-2007
thanks

I ll try it and try it develop.Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

^M special character in Filename

Hi All, Special character ? is added in between filename. Am not able to figure our why this is happening. In my Development environment special characters are not present. This issue is happening in the higher environment. It would be helpful if somebody can tell what are the possible... (3 Replies)
Discussion started by: weknowd
3 Replies

2. Shell Programming and Scripting

Finding a certain character in a filename and count the characters up to the certain character

Hello, I do have folders containing having funny strings in their names and one space. First, I do remove the funny strings and replace the space by an underscore. find . -name '* *' | while read file; do target=`echo "$file" | sed 's/... (2 Replies)
Discussion started by: tempestas
2 Replies

3. UNIX for Dummies Questions & Answers

BASH - Removing the very last character(s) extension of a filename

Hello. I would like to know how to do this in bash script : A_WORD="ABCD_EFGH.0.100.40.123" NEW_WORD=remove_last_ext("A_WORD") NEW_WORD --> ABCD_EFGH.0.100.40 A_WORD="ABCD_EFGH.0.50.3" NEW_WORD=remove_last_ext("A_WORD") NEW_WORD --> ABCD_EFGH.0.50 A_WORD="ABCD_EFGH.3.100.50." ... (2 Replies)
Discussion started by: jcdole
2 Replies

4. Shell Programming and Scripting

Remove last character from filename

Hi All, I have different type of file (.txt,.csv,.xml) format in my current directory. My requirement is that I need to remove the last character from the file format. Example count.txt$ csp_rules.csv^ Date.xml~ Need Output: count.txt csp_rules.csv Date.xml How to do that?.... (5 Replies)
Discussion started by: suresh01_apk
5 Replies

5. AIX

removing 8th and 9th character of a FILENAME

Hi everyone, I have a file called pdf.txt which has the following list inside: 7110412_1_31122012.pdf 7286510_4_46667100.pdf 4002176_1_00018824.pdf ... I need a looping script to REMOVE the 8th and 9th character of the filenames listed, no matter what character that is. So... (4 Replies)
Discussion started by: chipahoys
4 Replies

6. UNIX for Dummies Questions & Answers

Display last 8 character of filename

I would like to display the last 8 characters of the filenames for filenames of different lengths. I can delete the last 8 characters with sed but dont know how to only show the last 8 characters. The filenames are something like; afxH340800340000 afxH30800340021 afxR3080034002122 I... (3 Replies)
Discussion started by: Beanz
3 Replies

7. Shell Programming and Scripting

How to remove a newline character at the end of filename

Hi All, I have named a file with current date,time and year as follows: month=`date | awk '{print $2}'` date=`date | awk '{print $3}'` year=`date | awk '{print $6}'` time=`date +%Hh_%Mm_%Ss'` filename="test_"$month"_"$date"_"$year"_"$time".txt" > $filename The file is created with a... (2 Replies)
Discussion started by: amio
2 Replies

8. Shell Programming and Scripting

move filenames with to another filename without the last character ~

Hi, I need to move filenames with the following format below into filenames without the ~ like sample below. I hope you can help me create a simple unix script that will do this. Thanks in advance! move filename from: AIRS20081225-235641.BSP~ AIRS20081225-235648.BSP~ AIRS20081225-235640.BSP~... (3 Replies)
Discussion started by: ayhanne
3 Replies

9. HP-UX

special character on Filename.. help!!!urgent

I'm trying to rename a file name but the original file has a special character caused by typo. I've tried numerous combination of characters but the file name (original) is still not being recognized which in turn, would not allow me to rename the file. Can someone help? The filename is a... (1 Reply)
Discussion started by: genzbeat
1 Replies

10. UNIX for Dummies Questions & Answers

rsync problem - space character in filename

I have a freebsd box with a smb connection to a Windows server - I use rsync to copy specific directories, and files, between the two. The problem is the Windows box has files with space characters in their filenames and rsync fails to copy these. Reading the documentation of rsync it appears it... (3 Replies)
Discussion started by: chief2
3 Replies
Login or Register to Ask a Question