[ Date Index ]
[ Thread Index ]
[ <= Previous by date /
thread ]
[ Next by date /
thread => ]
[LUG]Re: Shell Scripting question
- To: list@xxxxxxxxxxxxx
- Subject: [LUG]Re: Shell Scripting question
- From: Peter Walker via list <list@xxxxxxxxxxxxx>
- Date: Thu, 26 Dec 2024 16:31:26 +0000
- Cc: Peter Walker <peter.walker@xxxxxxxxxxxxxxx>
- Content-language: en-US
- Delivered-to: dclug@xxxxxxxxxxxxxxxxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=dcglug.org.uk; s=1728723962; h=Content-Type:Cc:From:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Help:List-Id:Subject:Reply-To: In-Reply-To:MIME-Version:Date:Message-ID:References:To:Sender: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Archive; bh=STJOukt7oYI47sbZr0VGrtytvchOWQFvN8aAdSf0T1I=; b=GapiJH1LnPD3eY/2jYh8T25PcM vOa56gX96d4Yze0uLGoov/wB7FTolrrF3LSyn4GdO09PGgsfuk44NNgu0tiBUENRZOKyZ045P0sXv kYkyqtbjlNy1yPOz19U93tprl120n263evvIHVzmv4otdVv5UqdT11X/OR9HECmG9n/M=;
Hi Paul,
Post Christmas and Boxing Day dinners so no guarantees on details
but this is nice and easy to do in bash.
Like everything in Linux there are many ways of doing it so just
build from this.
You already have your files in a directory so you don't want to
list them explicitly.
If we assume we are in the directory then the linux globbing will
take care of that.
Eg.
ls *.mp3
Globbing just matches filenames based on the pattern you provide.
Your for loop was the right way to go and you just need to feed it
the correct list of files. Splitting the file names to make new
ones is an extra command so the easy option is to create a new
directory (new) to copy to and use the original names.
for file in *.mp3
do
ffmpeg -i $file -c copy -an new/${file}
done
To make it work with new file names we need an extra step.
for file in *.mp3
do
filename="${file%.*}"
ffmpeg -i $file -c copy -an ${filename}-ns.mp3
done
As I said, there are lots of ways of doing this sort of think.
Google xargs and bash scripting for more.
Cheers,
Pete
On 26/12/2024 11:37, zleap via list
wrote:
Hi, all
I am trying to write a shell script to auto mate a task of
stripping sound from some video files, as I am fairly new to
writing scripts I have so far found part of a solution
I have modified this
#!/bin/bash
echo Create files listed in an array with the touch command
files=(
# list of files to create
"file1.txt"
"file2.txt"
"file3.txt"
)
# Loop to create each file
for filelist in "${files[@]}"; do
touch "$filelist"
done
To include the target file names in the array
The following will strip from a single file
ffmpeg -i 20OCT5.mp4 -c copy -an 20OCT5-ns.mp4
So far I have modified so it applies the source file(s) listed in
the array
ffmpeg -i $filelist -c copy -an 20OCT5-ns.mp4
I am not sure what to put in to tell the script to slightly modify
the filename so the output file is modified for example
if the inputfile is
video.mp4 the output file with sound stripped is something like
video-ns.mp4
Can anyone advise further please, it is probably fairly simple for
someone with more shell scripting experience.
Thanks
Paul
--
The Mailing List for the Devon & Cornwall LUG
FAQ: https://www.dcglug.org.uk/faq/