Sponsored Content
Full Discussion: shell variables advanced
Top Forums Shell Programming and Scripting shell variables advanced Post 302339970 by Franklin52 on Saturday 1st of August 2009 08:44:04 AM
Old 08-01-2009
Quote:
Originally Posted by wakatana
I am sorry if i typed something which is un clearly. I have followings files in directory

Code:
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 01 - album - track001.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 02 - album - track002.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 03 - album - track003.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 04 - album - track004.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 05 - album - track005.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 06 - album - track006.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 07 - album - track007.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 08 - album - track008.mp3
-rw-r--r-- 1 marek marek 0 2009-07-31 20:37 09 - album - track009.mp3

what i am trying to do is rename to trackXXX.mp3

I found that can be done with

Code:
for jmeno in *.mp3
do
  cp $jmeno /tmp/`echo $i | sed "s/\([0-9]\{2\}\).*/track0\1.mp3/"`
done

but did not work for me. Also i searched and found that i have to change IFS variable.
Can you please advise me if this task can be done using using bash and for loop (not ksh), i am traying to learn something about bash scripting. Thanks
Something like this?

Code:
ls *.mp3 | awk '{system("cp " $0 " " $NF)}'

I've used the cp command but you can replace it with the mv command.

Regards
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Using shell variables In awk

Oh its not my day for syntax... cat gzipsize.txt | awk '{print "echo",$1,$2} > master.txt I have read a lot about the awk -v but haven't been able to get it to work. I have a variable in my script and I'm looking just to push it into the awk after the $2 (or anywhere would do)!!! Every... (11 Replies)
Discussion started by: nortypig
11 Replies

2. Shell Programming and Scripting

variables in shell

hi, i'm new in shell scripting and i'm working on bash on solaris 5.9 after try many stuff with unexpected results, i wonder: it is not posible in bash, to use a variable that was created inside a loop, out of it? i mean, for instance: cat mytext | \ while read text do viko=$text... (2 Replies)
Discussion started by: viko
2 Replies

3. Post Here to Contact Site Administrators and Moderators

Where can I download the VTC - Unix Shell Scripting Advanced complete video

Where can I download the VTC - Unix Shell Scripting Advanced complete video. I don't know in which thread I should post this question.Plz help me out, or just tell me the link in the reply to this post. Thanks in advance. (0 Replies)
Discussion started by: villain41
0 Replies

4. Shell Programming and Scripting

$0 shell variables

Would appreciate if someone can explain the ${0##*/} line. What does it do? I am aware that $0 is the script name, $# is number of arguments passed in, $* is all the arguments. With the curly brackets {} added in, what's the eventual effect? Does ${0##*/} actually equals $0$#$*? (something like... (3 Replies)
Discussion started by: new2ss
3 Replies

5. Shell Programming and Scripting

Advanced error handling in shell scripts

Hi all I've got a question regarding error handling in shell scripts. My background is mainly object oriented programming languages, but for a year or so I've been doing more and more (bash) shell scripting (which I quite enjoy by the way). To handle errors in my scripts I... (3 Replies)
Discussion started by: script_man
3 Replies

6. Shell Programming and Scripting

Shell advanced syntax?

I am not an expert of shell scripting, but I can do some simple things. Now, I read a script written by others and I need some help from the experts of this forum. Please help me to understand what is going on in this cycle: if ; then ] && \ export... (25 Replies)
Discussion started by: alt
25 Replies

7. Homework & Coursework Questions

Trouble with Advanced Shell Programming

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am working on a hands on project. We are creating a script for a corporate phone list. The project I am... (2 Replies)
Discussion started by: SarahBelle7858
2 Replies

8. Shell Programming and Scripting

awk - take variables out to shell

Hi, How could we take the value of awk variables out to shell? I know the following methods 1. awk '{print $1}' < file | read a echo $a 2. a=`awk '{print $1}' < file` echo $a Please let me know if there are any other methods. Also, how do we take more than 1 variable value... (4 Replies)
Discussion started by: Thumban
4 Replies

9. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

10. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies
DIR2OGG(1)						      General Commands Manual							DIR2OGG(1)

NAME
dir2ogg - Convert MP3, WAV, and M4A files to OGG format SYNOPSIS
dir2ogg [ options ] ( filename [filename2] ... || directory [directory2] ... || [cdrom-device] ... ) DESCRIPTION
dir2ogg converts MP3, M4A, WMA and WAV files to the open-source OGG format. dir2ogg is a python script that simply binds together mpg123, faad, and oggenc making it easier for the user to convert his/her music files. OGGs are about 15 to 20 percent smaller than MP3 files, with the same relative audio quality. dir2ogg can be called with the -d flag at the command line to convert any number of directories at once, or given MP3, M4A, WMA, and/or WAV filenames as arguments, dir2ogg will convert only those files. If converting WAV, M4A or WMA files with -d you must add the -w, -m or -W command line flags respectively. These flags are not neccesary unless using -d. Note that converting M4A files requires you to have faad installed, and converting WMA files requires mplayer. Keep in mind that converting from MP3 or M4A to OGG is a conversion between two lossy formats. This is fine if you just want to free up some disk space, but if you're a hard-core audiophile you may be disappointed. I really can't notice a difference in quality with 'naked' ears myself. General Options -h or --help print quick usage details to the screen. -d or --directory convert all MP3 files in directory. WAV and M4A files will be converted if used with the -w and -m command line flags. This option is for compatibility purposes only and does not need to be specified anymore. -r or --recursive like -d but descends recursively into directories. -c or --cdda Convert an audio CD into ogg. You may pass the device as an argument to the script (default: /dev/cdrom). Requires cdparanoia orq icedax or mplayer -p or --preserve-wav preserve all WAV files. By default they are deleted. -P or --no-pipe Do not use pipes to send data from the decoder to the encoder, use temporary wav files instead. --delete-input Delete the input file after conversion -v or --verbose increase dir2ogg's verbosity. -Q or --quiet Do not display progress messages, except the name of the file which is currently converted. Some decoders provide no way to disable messages and thus may still display some. Conversion options --convert-all Convert all supported audio files found in the directories given on the command-line to Ogg Vorbis. -f or --convert-ape Convert all APE (Monkey's Audio) files found in the directories given on the command-line to Ogg Vorbis, using either ogg123 or flac or mplayer. -f or --convert-flac Convert all FLAC (Free Lossless Audio Codec) files found in the directories given on the command-line to Ogg Vorbis, using ogg123 or flac or mplayer. -m or --convert-m4a convert all M4A (MPEG-4 Audio) files found in the directories given on the command-line to Ogg Vorbis, using faad or mplayer. For decoding ALAC (Apple Lossless) files, 'alac-decoder' may be used. -m or --convert-mpc convert all MPC (MusePack) files found in the directories given on the command-line to Ogg Vorbis, using mpcdec or mplayer. -W or --convert-wma Convert all WMA (Windows Media Audio) files found in the directories given on the command-line to Ogg Vorbis, using mplayer. -w or --convert-wav Convert all WAV files found in the directories given on the command-line to Ogg Vorbis. -V or --convert-wv Convert all WV (WavPack) files found in the directories given on the command-line to Ogg Vorbis. -n or --no-mp3 ingore all MP3 files found in directories given on the command-line. --(ape|cd|flac|m4a|mp3|mpc|wma|wv)-decoder=COMMAND Set the decoder you want to use for one filetype, e.g.: --mp3-decoder=lame. Run dir2ogg --help to see the available decoders. -qN or --quality=N OGG quality. N is a number between -1 and 10. Default is 3. Decimals are OK (ie: 3.7) -t or --smart-mp3 Try to use the same quality as the input file. MP3 input only! SEE ALSO
mpg123(1), mplayer(1), oggenc(1) BUGS
Enter you bug reports in Launchpad at https://bugs.launchpad.net/dir2ogg AUTHORS
0.10 and newer: Julian Andres Klode <jak@jak-linux.org> 0.9.3 and older: Darren Kirby <d@badcomputer.org> CONTRIBUTORS
original wma support: Cameron Stone <camerons@cse.unsw.edu.au> smart-mp3: Marek Palatinus <marek@palatinus.cz> dir2ogg 0.11.8 2009-08-04 DIR2OGG(1)
All times are GMT -4. The time now is 04:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy