05-18-2010
Appending file extensions to filenames in bash scripts
Hi
Suppose I have a variable called filename and it it contains the name of a file. I then would like to append an extension to that filename. The filename currently has no extensions.
How do I do this?
Thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Forgive the daft requests - I'm still a learner :D
I need a script so that I can test another script (I'm confused already) The script I am looking for should generate a new file in the same directory (called newfile1 or what ever) and also generate text within the new file (Hello world? What... (1 Reply)
Discussion started by: JayC89
1 Replies
2. UNIX for Dummies Questions & Answers
Hi,
I was wondering if there was a way to append something to filenames based on a wildcard. For example, if I have the following files in a directory:
blah1
blah2
blah3
blah4
blah5
I want to rename these all to:
blah1.txt
blah2.txt
blah3.txt
blah4.txt
blah5.txt
Is there a... (4 Replies)
Discussion started by: Djaunl
4 Replies
3. Shell Programming and Scripting
Hi,
I'm trying to write a script that reads filenames from a file and use these filenames in a loop. The filenames are all on one line and the problem is that these filenames have wildcards like * and braces like in them.
Right now what I'm doing is something like this:
echo "reading from... (0 Replies)
Discussion started by: warp17
0 Replies
4. Shell Programming and Scripting
Is there a way to link a script in my ~/bin with file extension priority for tab completion?
for example, if the script I have could only look at .tex files, and I have 6 files in the same directory with the same name, but different extensions:
index.tex index.dvi index.toc ... etc...
it... (0 Replies)
Discussion started by: pyramation
0 Replies
5. Shell Programming and Scripting
Hi,
I have to write a program to compute the checksums of files
./script.sh
I wrote the program using bash and it took me forever since I am a beginner but it works very well.
I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies
6. Shell Programming and Scripting
I'm working on a personal project, a multiplication quiz script for my kids. In it, the user's performance will be recorded and written to a file. After they've played it a little while, it will start to focus more on the ones that give them the most trouble-- that take a long time to answer or... (4 Replies)
Discussion started by: treesloth
4 Replies
7. Shell Programming and Scripting
Hello,
I have a file name in the below format and have to append the date as _$currdate.
kchik_UK_lo.txt_$currdate.
The above should be the format and I dont want to put entire filename as above in the code, but it should give me the output as the above filename.Can anyone please help... (7 Replies)
Discussion started by: harika03
7 Replies
8. Shell Programming and Scripting
Hi,
I wanted to load data from HDFS to HIVE by writing bash script.
Description:
I have written a bash script to validate the data and loaded validated data from local file system to HDFS. Now in the same bash script i wanted to load the data from HDFS to HIVE. How can i do it ? Also how tyhe... (2 Replies)
Discussion started by: shree11
2 Replies
9. Shell Programming and Scripting
Hi,
I have a script file where i'm validatig the input file and storing the validated records on HDFS.
I wanted to load data from HDFS to HBASE using pig script. So for that i have created a HBASE table and written pig script to load data from HDFS to HBASE which is working fine. Now i wanted... (0 Replies)
Discussion started by: shree11
0 Replies
10. UNIX for Beginners Questions & Answers
Hello.. and thanks in advance for any help anyone can offer me to figure this out
I'm reading about the about the Bash shell... and I've read from many sources that to make Bash POSIX compliant it needs "extensions"... Which sounds to me like something I should be able to load or unload into... (1 Reply)
Discussion started by: bodisha
1 Replies
LEARN ABOUT DEBIAN
mp3::tag::file
MP3::Tag::File(3pm) User Contributed Perl Documentation MP3::Tag::File(3pm)
NAME
MP3::Tag::File - Module for reading / writing files
SYNOPSIS
my $mp3 = MP3::Tag->new($filename);
($title, $artist, $no, $album, $year) = $mp3->parse_filename();
see MP3::Tag
DESCRIPTION
MP3::Tag::File is designed to be called from the MP3::Tag module.
It offers possibilities to read/write data from files via read(), write(), truncate(), seek(), tell(), open(), close(); one can find the
filename via the filename() method.
parse_filename()
($title, $artist, $no, $album, $year) = $mp3->parse_filename($what, $filename);
parse_filename() tries to extract information about artist, title, track number, album and year from the filename. (For backward
compatibility it may be also called by deprecated name read_filename().)
This is likely to fail for a lot of filenames, especially the album will be often wrongly guessed, as the name of the parent directory
is taken as album name.
$what and $filename are optional. $what maybe title, track, artist, album or year. If $what is defined parse_filename() will return
only this element.
If $filename is defined this filename will be used and not the real filename which was set by MP3::Tag with "MP3::Tag->new($filename)".
Otherwise the actual filename is used (subject to configuration variable "decode_encoding_filename").
Following formats will be hopefully recognized:
- album name/artist name - song name.mp3
- album_name/artist_name-song_name.mp3
- album.name/artist.name_song.name.mp3
- album name/(artist name) song name.mp3
- album name/01. artist name - song name.mp3
- album name/artist name - 01 - song.name.mp3
If artist or title end in "(NUMBER)" with 4-digit NUMBER, it is considered the year.
title()
$title = $mp3->title($filename);
Returns the title, guessed from the filename. See also parse_filename(). (For backward compatibility, can be called by deprecated name
song().)
$filename is optional and will be used instead of the real filename if defined.
artist()
$artist = $mp3->artist($filename);
Returns the artist name, guessed from the filename. See also parse_filename()
$filename is optional and will be used instead of the real filename if defined.
track()
$track = $mp3->track($filename);
Returns the track number, guessed from the filename. See also parse_filename()
$filename is optional and will be used instead of the real filename if defined.
year()
$year = $mp3->year($filename);
Returns the year, guessed from the filename. See also parse_filename()
$filename is optional and will be used instead of the real filename if defined.
album()
$album = $mp3->album($filename);
Returns the album name, guessed from the filename. See also parse_filename() The album name is guessed from the parent directory, so it
is very likely to fail.
$filename is optional and will be used instead of the real filename if defined.
comment()
$comment = $mp3->comment($filename); # Always undef
genre()
$genre = $mp3->genre($filename); # Always undef
perl v5.14.2 2009-11-28 MP3::Tag::File(3pm)