LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-13-2012, 09:47 AM   #1
dryfly
LQ Newbie
 
Registered: Jan 2007
Distribution: Mint, Xubuntu
Posts: 6

Rep: Reputation: 0
Question Simple Nautilus shell script driving me nuts!


This Nautilus Shell-script does a simple video format conversion of a selected file and outputs the file to output.mp4:

#! /bin/bash
FILE=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed q)
ffmpeg -i "$FILE" -sameq -s hd720 "output.mp4"

but if I try to incorporate the original filename into the output, it does nothing!!

#! /bin/bash
FILE=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed q)
output="conv."$FILE".mp4"
ffmpeg -i "$FILE" -sameq -s hd720 "$output"

WHY???
 
Old 12-14-2012, 03:31 AM   #2
bijo505
Member
 
Registered: Nov 2012
Location: Bangalore
Distribution: Fedora & Ubuntu
Posts: 77

Rep: Reputation: 18
Hi,
Try to run the script in debugging mode, so you will get to know, where it is breaking

Eg: bash -bvx <scriptname>

-b Notify of job termination immediately.
-v Print shell input lines as they are read.
-x Print commands and their arguments as they are executed.

--
Thanks,
Bijo
 
Old 12-14-2012, 06:55 AM   #3
dryfly
LQ Newbie
 
Registered: Jan 2007
Distribution: Mint, Xubuntu
Posts: 6

Original Poster
Rep: Reputation: 0
I hard coded the selected file into the script and ran it with debugging and it worked, but it won't work as a Nautilus shell script.

I modified the script slightly and added the mv line at the end to attempt to force a name change after the conversion is done. The conversion works OK but the mv line is never executed. I'm flummoxed!

#! /bin/bash

FILE=$(echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | sed q)

temp="temp.mp4"
output="conv."$FILE

ffmpeg -y -i "$FILE" -sameq -s hd720 "temp.mp4"

mv $temp $output
 
Old 12-14-2012, 03:59 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,739

Rep: Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921Reputation: 5921
$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS returns the full path to the file so your output file name would be

conv./path/to/file/name.ext.mp4

Slashes are illegal characters in file names which is why your script does not work. If you desire to have your file named as conv.filename.mp4 then you need to strip the path and filename first and recombine it so it looks like

/path/to/file/conv.base_file_name.mp4


http://linuxgazette.net/18/bash.html

Last edited by michaelk; 12-14-2012 at 05:23 PM.
 
Old 12-15-2012, 06:27 AM   #5
dryfly
LQ Newbie
 
Registered: Jan 2007
Distribution: Mint, Xubuntu
Posts: 6

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS returns the full path to the file so your output file name would be

conv./path/to/file/name.ext.mp4
Doh! THAT must be why the variable has the word PATH in its name. I'm afraid that was too obvious for me. Here I was looking for some really obscure "feature" of bash. Many thnks for the link to the tutorial.

Geoff
 
  


Reply

Tags
filename expansion, nautilus, script, shell



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
Help - it's driving me nuts! n4ogl Linux - Newbie 4 11-13-2005 09:28 PM
Driving me nuts!! jappstam12345 Linux - Newbie 7 03-11-2005 05:51 PM
This is driving me nuts! dareino Fedora 4 06-30-2004 02:17 AM
Simple shell script is driving me crazy ner Linux - Newbie 4 01-28-2004 10:50 AM
driving me nuts!!! ihatebillgates Linux - Newbie 6 12-12-2003 07:03 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration