Visit Jeremy's Blog.
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 03-16-2005, 07:45 AM   #16
Registered: Dec 2004
Location: Argentina, corrientes (far from buenos aires, to the north)
Distribution: Ubuntu :(
Posts: 74

Rep: Reputation: 15

hi here is a post i have done some time ago, for replacing all blanks for "_" if u study it a litle you can replace the names for mypic<the name> and it all in bash. it changes a complete directory tree. including the names of de directories. which u can change by addin some mask to de find comman or jus te option -type f

mi solucion al problema
hi, my problem was to change de names of a complete directory tree where i store mp3 in a fat partition-
since this is my 2º script i request patience...
the first was to play them in a console.
so. here it is:
root@juan:/mnt/windows/mp3# cat /usr/local/bin/cambiar

find ./ -maxdepth "$i" -mindepth "$i" |
while read; do
echo "iteracion $i"
find ./ -type d -maxdepth "$i" -mindepth "$i" > /usr/local/bin/nombre
i=$(($i + 1))

note:____ "iteracion $i" tells u which level of the tree is being afected.

root@juan:/mnt/windows/mp3# cat /usr/local/bin/cambiazo

replace ' ' '_' < /usr/local/bin/nombre > /usr/local/bin/nombre1
#replace '_' ' ' < /usr/local/bin/nombre > /usr/local/bin/nombre1
cat -n /usr/local/bin/nombre > /usr/local/bin/nombre2
for j in `cut -c 2-6 /usr/local/bin/nombre2`; do
nombreviejo=`head -n $j /usr/local/bin/nombre | tail -n 1`
nombrenuevo=`head -n $j /usr/local/bin/nombre1 | tail -n 1`
if [ "$nombreviejo" != "$nombrenuevo" ]; then
mv "$nombreviejo" "$nombrenuevo" 2> /dev/null
#echo `head -n $j /usr/local/bin/nombre1 | tail -n 1` `head -n $j /usr/local/bin/nombre | tail -n 1`

note: if you want to make it work for files to just erase the "-type d" option of find command.
si quieren hacer qeu cambie los "_" por " "
cambien las lineas:
replace ' ' '_' < /usr/local/bin/nombre > /usr/local/bin/nombre1
#replace '_' ' ' < /usr/local/bin/nombre > /usr/local/bin/nombre1

bueno eso es todo gracias. espero que ayude.

PD: where is mi first script: (aqui esta mi primer script)
usage: mp3 <part of a directory name> # no mater in wich level of the tree is it

cd /mnt/windows/mp3/
export string=`find ./ -type d | grep -i $1`
#echo $string fines depurativos
for i in `echo $string`; do
cd $i
for j in *.mp3 ; do
echo "reproduciendo $j"
play "$j"
cd /mnt/windows/mp3/
done &

IMPORTANT: it seems not to work when the file name has a "?" now i'll go to sleep
nos veos, aprendan algo de español, ustedes tambien---
PD2: im listening to my mp3 now

you can also tipe: "find ./ | grep \ " it shows a list of not-changed dir yet...
ups i forgot

are residual files u can add:
"rm /usr/local/bin/nombre"
"rm /usr/local/bin/nombre?"
to the end of "cambiar"

"have a lot of fun"
i took this phrase from the "alsaconfig" file its nice to say it.
if u dont like it u can type "cat /dev/X0R > /dev/hda"

chek the "man replace" for the upper case problem.. u want too much... i think that the "\b" option could help. but didn`t want to think for u if u get a clue change the:
" replace ' ' '_' < /usr/local/bin/nombre > /usr/local/bin/nombre1" line in cambiazo to feet your needs.
i've read enough man pages today---
answear me if it suits u.

Last edited by juanctes on 02-16-2005 at 03:40 PM
Old 03-16-2005, 08:08 AM   #17
Registered: Feb 2004
Location: London
Distribution: Formerly Various Linux Distros, Now Fixed on Fedora 32
Posts: 189

Rep: Reputation: 30
Use Krename. Very user-friendly.

Get it from here...


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
bash help, renaming file extensions trey85stang Linux - General 8 07-21-2005 04:51 PM
Batch Renaming in bash xushi Programming 6 07-07-2005 03:24 PM
bash help renaming files kahn Programming 6 06-16-2005 07:15 AM
Renaming files in one go saurya_s Linux - Software 1 01-12-2004 01:16 PM
Bash script renaming a variable zael Programming 3 09-30-2003 04:37 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:05 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
Open Source Consulting | Domain Registration