help removing characters for output file in shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help removing characters for output file in shell script
# 1  
Old 08-02-2008
help removing characters for output file in shell script

hi i'm new to shell scripts and have a small problem

i am running a batch converter that returns all flash .flv files in a directory and create a png image from each one

Quote:
#!/bin/bash
echo "flv-to-png converter"
echo ""
if (($# ==0))
then
echo "Usage: flvtopng [flv files] ..."
exit
fi
while (($# !=0 ))
do
ffmpeg -i $1 -vcodec png -vframes 1 -an -ss 00:00:08 -t 00:00:01 -f rawvideo -s 320x240 /var/www/vhosts/mysite.com/httpdocs/playerimage/$1.png
shift
done
echo "Finished with flv-to-png converter"
echo ""
the problem i have is the $1 variable , its ok on the first call but on the secound call $1.png , i have extra characrters that i need to strip from this element

for example on the first call of $1 it produces 997.flv on the secound call $1.png and outputs a resulting 997.flv.png

i need to strip the .flv part from 997.flv.png to return only 997.png (strip 4 characters from the end of $1 on its secound call - this whould be the same on all resulting files in a directory full of files as this shell script runs)

how can i do this, is it easy or is it complex, any help with this issue would be very usefull, i have tryed searching google, but can not fing out how to strip characters from a varablie in shell scripts

thanks in advance

Last edited by wingchun22; 08-02-2008 at 12:28 AM..
# 2  
Old 08-02-2008
This should work:
Code:
ffmpeg -i $1 -vcodec png -vframes 1 -an -ss 00:00:08 -t 00:00:01 -f rawvideo -s 320x240 /var/www/vhosts/mysite.com/httpdocs/playerimage/${1%.*}.png

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Removing characters and some output

Hi guys, So I am using an awk command to return a specific column in a file. I also need to remove some extra characters. What I have is :: (http-/0.0.0.0:8091-9)|23:00:41 And what I want is : http-/0.0.0.0:8091-9 I tried using the td command but it is only removing the ( ,... (5 Replies)
Discussion started by: Junaid Subhani
5 Replies

2. Shell Programming and Scripting

Removing last and first characters in a file

bash-3.00$ cat temp.txt ./a/REA01/ces1/apps/ces_ces1_init3_aa.ear/ces.war/WEB-INF/classes/reds/common/environment.properties ./a/REA01/ces1/apps/ces_ces1_init3_aa.ear/commonproperties/hi/HostIntegration.properties... (9 Replies)
Discussion started by: bhas85
9 Replies

3. UNIX for Dummies Questions & Answers

[Solved] Removing control-m characters from shell script

Hi All, I need to remove control m character from a file. Steps which i am doing in shell script are: 1) We are comparing the header of the file to the database table header Here the file header has control-m characters. How do i remove it. Please help. Below are the steps i am using,... (12 Replies)
Discussion started by: abhi_123
12 Replies

4. Shell Programming and Scripting

Removing lines from a file being used by another process using SHELL script

Hi All, Need a small help in writing a shell script which can delete a few lines from a file which is currently being used by another process. File gets appended using tee -a command due to which its size is getting increased. Contents like : 25/09/2012 05:18 Run ID:56579677-1 My... (3 Replies)
Discussion started by: nikhil8
3 Replies

5. Shell Programming and Scripting

Removing Characters From finger Output

Hi Does anyone know of a command that will extract only the Login name alison and year 2005 from the following output. jamesm> finger alison Login name: alison In real life: Alison Smith - Queensland Directory: /data/home/alison Shell: /usr/bin/ksh... (2 Replies)
Discussion started by: jamba1
2 Replies

6. UNIX for Dummies Questions & Answers

shell script to find noof characters in a file name

hiiii shell script to find noof characters in a file name, when you run ls -l (using awk) I tried with this ls -l > temp awk -F"," '{print $1 " " expr length $9}' temp but it give some other value instead of file name length (error value like , 563,54,55,56....).How to prnint the... (10 Replies)
Discussion started by: krishnampkkm
10 Replies

7. Shell Programming and Scripting

Removing ^M characters from a file

Hi, I want to removing ^M characters from a file and combine the line with the next line. ex: issue i have: ABC^M^M DEF solution i need: ABCDEF I found that you by using the following command you can remove new line characters. tr -d '\r' < infile.csv > outfile.csv still... (10 Replies)
Discussion started by: mwrg
10 Replies

8. Shell Programming and Scripting

Removing the entire file contents using unix shell script.

I need to remove the entire file contents in file using the shell script. Actually the grap -v command will create one more file and it occupy the space also. I need to remove the entire file contents without creating new file using the shell scripting. Please help me. (5 Replies)
Discussion started by: praka
5 Replies

9. Shell Programming and Scripting

Bold characters in a file using Shell script

Hi, When I am running below mentioned script then the characters become bold but after opening the same file in Windows, Instead of getting bold characters i am getting some garbage value for \033Kunal Dixit Output in Windows (after ftp the file): but in windows , i am getting My name is... (0 Replies)
Discussion started by: kunal_dixit
0 Replies

10. Shell Programming and Scripting

Removing certain characters in a file

Hi I have a file that has semicolons in it (;) is there a way to just remove these in the file. Example name: Joe Smith; group: Group1; name: Mary White; group: Group2; (2 Replies)
Discussion started by: bombcan
2 Replies
Login or Register to Ask a Question