Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
now at them moment it converts the biggest avi it finds in the folder for my archos to use at work, i need it to convert all avis in the folder
im guessing its not as simple as replacing "$file" with "*.avi" or is it? (and changing the end to *_done.avi to insure the end file is named correctly?)
test it out to be sure, but something like this might do the trick...
Code:
dir=$1
cd "$dir"
for i in $(ls -1 *.avi)
do
file="${i}" ; echo $file >> /home/mrgreaper/conv.text
mencoder "$file" -ovc xvid -oac mp3lame -xvidencopts bitrate=748:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o /home/mrgreaper/archos/"$file"_DONE.avi
done
i triedmaking a bash script but got ./bash is a director lnux really ant my strong point lol
but have amended a new conversion post processing script and am trying it out , i wont know for a few hours if its worked (well if it errors fully ill know in a few minutes lol)
Thank you in advance ill post how it goes when its done
***edit***
while i tried to find sabnzbds script folder episode butler (i use this rather then a vcr so i can watch my programs at work lol, as far as i know nothing illeagel is going on after all its the same as taping it) picked up some programs fed them into sabnzbd which then downloaded and is running post processing scripts on them (it does them one at a time in order) so i wont know if that script has worked for a very long time (the new one that is) oh well fingers crossed
pardon the triple post but it serves a purpose of bumping the thread to get noticed and this is a new winkle and editing would mean it would go un noticed.
ok the script as
Code:
IFS='
' files=( $(/bin/ls -1 '--ignore=*_done.avi' *.avi) )
for (( i = 0; i < ${#files[*]}; i++ ))
do
file="${files[$i]}"
mencoder "$file" -ovc xvid -oac mp3lame -xvidencopts bitrate=748:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o /home/mrgreaper/archos/"$file"_DONE.avi
done
and run by ./conv3 from inside the folder full of avi files (providing the conv3 file is in the folder too) works great it works perfectly
but the post processing script as
Code:
dir=$1
cd "$dir"
IFS='
' files=( $(/bin/ls -1 '--ignore=*_done.avi' *.avi) )
for (( i = 0; i < ${#files[*]}; i++ ))
do
file="${files[$i]}"
mencoder "$file" -ovc xvid -oac mp3lame -xvidencopts bitrate=748:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o /home/mrgreaper/archos/"$file"_DONE.avi
done
generates the following error
/home/mrgreaper/sabnzbd/script/conv3: 5: Syntax error: "(" unexpected
both have been chmod 777
i just dont get it
a possible solution springs to mind if i could make conv3 executable from anywhere (is that possible? ie being able to ./conv3 with out the file being in the folder im in and it still converting all the files of the folder im looking at?)
if thats possible i could do this
Code:
dir=$1
cd "$dir"
./conv3
the $1 is the completed folder directory passed on by sabnzbd and works fine in the first example i gave in the first post
if thats not possible the only other thing i can think of is this;
Code:
dir=$1
cd "$dir"
copy file command (im sure i can find that on google lol) /home/mrgreaper/sabnzbd/script/conv3 to "$dir"
./conv3
i wish i had the time and patience to really learn linux cos it just makes no sense that inside a terminal window the script works but as a post script (which is just being activated in a terminal as far as i can tell) it errors arghhhhhhhhhhhhhhhh
No problem with posting again in the same thread -- it's the same problem and isn't solved yet.
"/home/mrgreaper/sabnzbd/script/conv3: 5: Syntax error: "(" unexpected" is a syntax error, nothing to do with permissions on the script file.
Perhaps the script is running in a different shell when it is run as a post-processing script. Do you know and can you post details of how it is being launched?
Try setting the first line of the script to this (if it is not already); It may force the script to be executed by bash.
Code:
#!/bin/bash
You can run the script regardless of which directory you are in by specifying it with a full path, for example as
Code:
/home/<your user name>/bin/conv3.sh
Here "bin" is a common convention for a directory name to put executables in and the extension .sh is a common convention for shell scripts.
To copy files, use the cp command, details by running
Code:
man cp
or by netsearching.
Last edited by catkin; 09-14-2009 at 04:04 AM.
Reason: Missing /
dir=$1
cd "$dir"
for file in *.avi
do
mencoder "$file" -ovc xvid -oac mp3lame -xvidencopts bitrate=748:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o /home/mrgreaper/archos/"$file"_DONE.avi
done
by and by, which archos do you have. i have an archos av500 dvr and the video recording is horrible (mite be because it is a hand me down). does yours record fairly decently ?
dir=$1
cd "$dir"
for file in *.avi
do
mencoder "$file" -ovc xvid -oac mp3lame -xvidencopts bitrate=748:aspect=16/9 -lameopts br=80 -vf scale=424:234 -o /home/mrgreaper/archos/"$file"_DONE.avi
done
by and by, which archos do you have. i have an archos av500 dvr and the video recording is horrible (mite be because it is a hand me down). does yours record fairly decently ?
av700 tv (tv part is good when hooked into an arial as its a digibox but the portable arial doesnt work at work (but then i guard a carpark and am surrounded by steal and concreate lol)
the recording on it is oversized and blocky so i use episode butler to get my tv programmes for me (again as far as i can see thats no different then setting a vcr up except its in a format i can do something with lol)
i then use mencoder to put it into a smaller file size and make sure the audio is the right codec etc
as for the change of script i added the bash bit (gedit automaticly changed the colours of some of the words, i guess to make scripting easier) tested it on a 1 avi file folder and it worked now just have to wait for it to work on a multi avi link (my net is being slow at mo (i norm 5000+k per second (around 5meg a sec actual) im getting 1200 k per sec
Use schneidz's way instead, which is not only easier and more efficient but also more solid.
However, if
catkin's method does seem to be working now i added the bash bit so im loathed to change it plus if i make file = *.avi would that not just make file = test.avitest2.avitest3.avi ?
The for loop will work *always*. Just read that link I gave you to see why using the ls output as your source is not reliable. ls wasn't designed for that purpose, though it's a common practice for I don't know what reason, that doesn't make it any more correct.
av700 tv (tv part is good when hooked into an arial as its a digibox but the portable arial doesnt work at work (but then i guard a carpark and am surrounded by steal and concreate lol)
the recording on it is oversized and blocky so i use episode butler to get my tv programmes for me (again as far as i can see thats no different then setting a vcr up except its in a format i can do something with lol)
i then use mencoder to put it into a smaller file size and make sure the audio is the right codec etc
...
for me my av500 dvr gives a low screach when connected to my tv thru rca a/v composite and the output looks wavy (like bad uhf/ vhf)
but again mite be because i got this from a freind after he got it from a friend. (the outer casing is missing some small screws. the battery/ harddrive compartment is taped shut.)
i am wondering if buying a new unit will solve that ?
I guess most of us use ls because we are scripting using a toolset we use interactively. About the final recommendation
Code:
find . -type f -print0 | while IFS= read -r -d '' filename; do
...
done
Presumably the "IFS=" is defensive, in case IFS has been set to a non-standard value, and so is redundant in most cases.
It's not redundant, the standard value of IFS is blank/tab/LF, this serves the purpose of setting the internal field separator to null. This is important because spaces, tabs and LF characters can be part of a file name, but null can't. This is *the only way* to ensure that your script will always behave OK; with independence on how odd your file names are
That's the purpose of the -print0 statement as well. This instructs find to use the null character to separate the elements of the list.
This is why you use IFS=, or xargs -0 in conjunction with the find -print0 option.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.