LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 11-25-2011, 07:17 AM   #16
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206

Quote:
Originally Posted by Foxbat1155 View Post
I have written a file with

foo=( e i u )
bar=( c a e i o u a e i o u a e i o u y a e i o u a e i o u )

i=${#bar[@]}

while [ $i -gt 0 ]; do
i=$((i-1))
rename "s/${foo[$i]}/${bar[$i]}/g" "$@"
done


but this has resulted that when I invoke it on the terminal it just stays on an infinite loop, apparently, as it does nothing and then I have to do ^C to stop it and then I do ls and it is all the same.

Any suggestions for modifications?
Are you passing it arguments? Like:

Code:
./script.sh weird__filename
 
1 members found this post helpful.
Old 11-25-2011, 07:20 AM   #17
Foxbat1155
Member
 
Registered: Oct 2011
Location: Portugal.
Distribution: Debian squeeze - Fluxbox.
Posts: 109

Original Poster
Rep: Reputation: 0
Question ok

I see, thankyou. But what I would really like is to invoke a command and have it check all filenames and directory names in the directory where I am at. And change them accordingly, if needed.
 
Old 11-25-2011, 07:26 AM   #18
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
You could use the script in combination with find. This runs the script on every file/dir below current dir.

Code:
find . -exec ./script.sh {} \;
Might want to add a -n to the rename command before you try such a thing.
 
1 members found this post helpful.
Old 11-25-2011, 07:28 AM   #19
Foxbat1155
Member
 
Registered: Oct 2011
Location: Portugal.
Distribution: Debian squeeze - Fluxbox.
Posts: 109

Original Poster
Rep: Reputation: 0
Cool thankyou

Thankyou Sir Williams, that was very useful =)
 
Old 11-25-2011, 09:09 AM   #20
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
Here are a couple of tools that may help you. Why make your own replacement script if the heavy work has already been done for you?

http://www.nongnu.org/unac/unaccent-man1.en.html
http://detox.sourceforge.net/

Also, everyone, please use [code][/code] tags around your code, to preserve formatting and to improve readability.
 
1 members found this post helpful.
Old 11-25-2011, 09:13 AM   #21
Foxbat1155
Member
 
Registered: Oct 2011
Location: Portugal.
Distribution: Debian squeeze - Fluxbox.
Posts: 109

Original Poster
Rep: Reputation: 0
thankyou

Thankyou Sir David.
 
  


Reply

Tags
batch, rename, script, shell


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
[SOLVED] Errors executing shell script: "command not found" and "no such file or directory" eko000 Linux - Newbie 1 01-14-2011 07:54 AM
Shell script: I have string "abc____def____ghi", how to make "abc def ghi" vouser Programming 8 03-09-2010 10:01 PM
Problem in compile library file command "make" reallynewbie2009 Linux - Newbie 4 09-14-2009 10:04 AM
So many errors when I typed the "make" and "make install" command Niceman2005 Linux - Software 23 07-22-2009 02:33 PM
"make" command not working in shell unasriseth Linux - Newbie 6 05-25-2004 09:08 AM


All times are GMT -5. The time now is 04:56 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