Sponsored Content
Top Forums Shell Programming and Scripting help removing characters for output file in shell script Post 302220872 by wingchun22 on Friday 1st of August 2008 11:23:05 PM
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..
 

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
PNGNQ(1)							   User Manuals 							  PNGNQ(1)

NAME
pngnq - quantize png images SYNOPSIS
pngnq [-vfhV][-s sample_factor ][-Q dither ][-g gamma ][-e extension ][-d dir ][-n colors ][ inputfiles ] DESCRIPTION
pngnq Quantizes a 32-bit RGBA PNG image to an 8 bit RGBA palette PNG using the neuquant algorithm. The output file name is the input file name extended with "-nq8.png" or a specified extension. OPTIONS
-v Verbose mode. Prints status messages. -f Force ovewriting of files. -s sample factor Sample factor. The neuquant algorithm samples pixels stepping by this value. The default value of 3 gives good results. Higher val- ues sample less of the image pixels and thus are faster but less accurate. A factor of 1 samples every image pixel. -n colors Specifies the number of colors to quantize to. Defaults to 256 which is the maximum. The minimum here is 2. -Q dither Choose a dithering method: n = no dither (default), f = Floyd Steinberg dithering. -g gamma Set the image gamma correction. If not present, uses the png file's gamma or defaults to 1.0. -e extension Specifies the new filename extension. Defaults to "-nq8.png". Pngnq drops .png from the original filenames. If you set the argument of the -e option to .png and choose the -f option the input file will be overwritten. -d dir Tells pngnq to put output files in a directory other than the one the input files are in. input files The png files to be processed. Defaults to standard input if not specified. If standard input is being processed the output is sent to standard output. -h Print program help. -V Print version number and library versions. BUGS
Does not deal correctly with greyscale alpha images with low bit depths, but these wont benefit from quantizing. AUTHOR
Stuart Coyle <stuart.coyle@gmail.com> SEE ALSO
png(5) Linux MAY 2009 PNGNQ(1)
All times are GMT -4. The time now is 08:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy