got an insanely simple and working script already: #!/bin/bash -x  mkdir .before mkdir .error for i in *.m??; do         ffmpeg -n -i &quot;$i&quot; -b:a 16k &quot;${i%.*}.opus&quot; &amp;&amp; mv &quot;$i&quot; .before/         mv &quot;$i&quot; .error/ done  echo zzz finished $TITLE | termux-notification termux-vibrate -f  of course the important command is just ffmpeg there, but just keep in mind my context, please. termux. android only. simplicity... and immensely reducing my music collection size! everything works fine with this... except for my minor issue of the week: the album art is lost! there are many questions in sen dealing with this, and  it's actually way more complicated than it may appear at first sight. the only proclaimed solution i could find so far is a script from 2014 which doesn't handle opus:  can you help me keeping this simple? or else, i will just output it to a image file of same name and deal with it another year. 😒 edit:  doesn't really answer the question. it solves the album, but i can't find a configuration with opusenc which keeps the file at 10%. setting the same bitrate (16k) gets it to 20% at best.
120627
I am trying to convert some flac files which all have coverart embedded to opus with ffmpeg. All but the coverart gets copied over just fine, but I find myself unable to move the cover over as well. Tried all sorts of -mapmetadata stuff I could find so far, but no luck, the result is always missing the coverart.  While the original .flac reports to have a video stream with the coverart  Duration: 00:02:53.51, start: 0.000000, bitrate: 910 kb/s    Stream #0:0: Audio: flac, 44100 Hz, stereo, s16    Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 500x500 [SAR 1:1 DAR 1:1], 90k tbr, 90k tbn, 90k tbc   the created opus files does not have any graphics:  size=    2815kB time=00:02:53.51 bitrate= 132.9kbits/s speed= 104x video:0kB audio:2793kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.811556%   I tried -vcodec copy, -mapmetadata 0, -mapmetadata 0:s:0 so far, with no luck. Doesnt seem to have anything todo with opus, as I have the same problem converting to aac.  So is there a way to get the cover out of the flac file and move it over to the new file in on go using ffmpeg, or do I have to extract it first and then glue it back again later to the new file with extra commands?
41971
I have a bash script which enumerates through every *.php file in a directory and applies iconv to it. This gets output in STDOUT.   Since adding the -o parameter ( in my experience ) actually writes a blank file probably before the conversion takes place, how can I adjust my script so it does the conversion, then overwrites the input file?  for file in *.php do     iconv -f cp1251 -t utf8 "$file" done
70127
I'm looking for a bash script that will detect when a file enters a specific folder. Basically I want to eventually make a script that will detect when a file enters a certain folder on my desktop (using windows with wsl), add .png to the end of the file name (long story, just need that to happen), and then move to another file on my desktop. I have something to rename the files, as a friend made it and we worked together to troubleshoot it   for i in /[directory here] ; do mv "$i" "$i.png" ; done   Now I just need to automate it. I don't want to bother him more, since he has already done so much, and I am too new to Ubuntu to understand exactly what to do
25290
I have a script as below:  #!/bin/bash df -k | tr -s " " "," | awk 'BEGIN {FS=","} {print $1,$5}'|sed 1d &gt; file1.txt while read partition percentUsed do if [ $percentUsed &gt; 75 ] then echo Partition: ${partition} space is ${percentUsed} else echo Pration: $partition: OK!! fi done &lt; file1.txt   The script is executing properly, however, it is creating a zero byte file by the name 75. Any ideas why this is happening?  $ sh diskUsed.sh Partition: C:/Users/Public/Documents/CYGWIN/bin space is 75% Partition: C:/Users/Public/Documents/CYGWIN/lib space is 75% Partition: C:/Users/Public/Documents/CYGWIN space is 75% Partition: C: space is 75% Partition: H: space is 91%   $ ls -lrt total 2 -rwxrwxrwx 1 diwvibh Domain Users 284 Nov 21 04:17 diskUsed.sh -rw-r--r-- 1 diwvibh Domain Users 133 Nov 21 04:29 file1.txt -rw-r--r-- 1 diwvibh Domain Users   0 Nov 21 04:29 75
68694
Before I run this, I want to make sure it is correct. I want to delete any .deb files. find /home/andy/.local/share/Trash/expunged/ -type f -exec rm *.deb  This works on all files except .deb files. #!/bin/bash find /home/andy/.local/share/Trash/expunged/ -type f -exec rm {} \; find /home/andy/.local/share/Trash/files/ -type f -exec rm {} \; find /home/andy/.local/share/Trash/info/ -type f -exec rm {} \;  And it works completely with UM 20.04.
29238
As it was suggested  I am using cat command to concatenate several .mp3 files into one .mp3 file. Imagine, I have following .mp3 files in the current folder: 001001.mp3 001002.mp3 001003.mp3 001004.mp3 001005.mp3  or, like this: 096001.mp3 096002.mp3 096003.mp3 096004.mp3  I need to concatenate these .mp3 files in there ascending sequence, i.e.  001001.mp3+001002.mp3+001003.mp3+etc. In order to join these .mp3 files into one I am executing following command in the current folder: cat *.mp3 &gt; final.mp3  I tested the final .mp3 file and it is what I am expected, but I need to be sure that above command picks files in there ascending sequence. Can I be sure that above command always concatenates files in the ascending sequence? Thank you Sir!
75140
I have the following shell script that sums up all the arguments passed to it (space separated):  sum=0 for arg in "$@"; do     (( sum += arg )) done echo $sum   I have saved it as SumAll.sh. So, its supposed to function as follows:  sh SumAll.sh 2 4 6 8 20   or  bash SumAll.sh 1 -2 3 -3 -1   Both work on my local machine (MacBook), but when I try the same in a linux server, running the script with bash works, but with sh does not work. I get the following error:  sum: '+=': No such file or directory sum: arg: No such file or directory   Why is that? And how do I fix it?
37773
I wrote a bash script that processes a list of filenames (using glob expansion, as in for f in *) and then outputs a subset of this list to a file. Subsequently I read the content of this file into an array and perform a plain binary search for specific filenames using the obvious &lt; and &gt; operators for comparing strings.  Considering that I would like the script to work on as many different environments like Linux, MacOS, MinGW, ... (even though it uses things like [[ and stat which are less portable), my questions are:   Do I need to sort the file content (either with sort or additional bash code) or is the glob expansion always sorted - in every environment? Do the conditional operators use the same "sorting" as the expansion (or after sort)?  Would expansion or sort return file10.txt after file2.txt (in what cases?) but using conditional operators file10.txt would be before file2.txt ? What sort option would I  use to fix this? Are there any caveats if some of my filenames are in Unicode?   Are there any issues using specific versions of bash?   Does LC_COLLATE affect any of the above?     I obviously need the file content to match the sorting "method" of the operators in order for the binary search to work as expected...
110327
I have separate scripts for tasks in bash. Here is the broken one:  #!/bin/bash PATH=/home/name/ mkdir $PATH cd $PATH &amp;&amp; echo "done." exit 0   Today it broke and first time it simply didn't want to run cd, but created directory. Second time it just said "mkdir command not found." Running this commands exactly with semicolon works fine. What the case?
103349
I don't get this:  script: WORKDIR/sh/script.sh  [ -e filename ]          \ &amp;&amp; echo filename         \ || [ -e ../filename ]    \ &amp;&amp; echo ../filename      \ || { echo 'ERROR: failed to find "filename"' 1&gt;&amp;2 ; exit -1; }   output:  $ cd WORKDIR/sh $ ./script.sh ../filename  $ cd WORKDIR $ sh/script.sh filename ../filename      # &lt;---- WHY????   My thoughts:  1  [ -e filename ]          \ -&gt; false &amp;&amp;                         -&gt; skip this, it is already false    echo filename         \ -&gt; don't even try || [ -e ../filename ]    \ -&gt; true &amp;&amp; echo ../filename      \ -&gt; true ||                         -&gt; already true, skip the rest    { echo 'ERROR: failed to find "filename"' 1&gt;&amp;2 ; exit -1; }   2  [ -e filename ]          \ -&gt; true &amp;&amp; echo filename         \ -&gt; true ||                         -&gt; already true, skip the rest    [ -e ../filename ]    \ &amp;&amp; echo ../filename      \ || { echo 'ERROR: failed to find "filename"' 1&gt;&amp;2 ; exit -1; }   version:  bash --version GNU bash, version 4.4.12(1)-release (x86_64-pc-linux-gnu)
80577
I am trying to create directory in bulk using mkdir through shell script below is the script  #!bin/bash mkdir /tmp/report*/testfolder*/testdoank   when i run it i got an error  -bash: ./makefolder.sh: bin/bash: bad interpreter: No such file or directory   what is wrong?
72476
My current best bet is:  for i in $(find . -name *.jpg); do echo $i; done   Problem: does not handle spaces in filenames.   Note: I would also love a graphical way of doing this, such as the "tree" command.
48925
It's hard to search for special characters on google, which is why I'm posting this here.  I recently ran (as root) a mv /tmp/folder/* /* when I meant to run mv /tmp/folder/* ./ Big mistake!  Things broke! A lot of files got mixed up and placed into strange places, none of the normal unix commands worked (ls, dir, cat, etc) and once you logged off, you couldn't ssh back in -- it would give you a prompt, but not accept the old passwords.  Running ls /* shows me that it performs ls on every directory in /. If I tried to draw a parallel, then mv should have simply moved (or copied?) the files to every directory in /. Instead, really weird things happened, and I was just curious what exactly was going on.  More info: The files in /tmp/folder had been transferred from a windows machine, and had been named file (#).txt, where (#) is a number up to two digits, with a space between file and the parenthesis. There were ~40 of these text files.
79640
What I want to do: I have a folder with a great bunch of images. Using these files I want to create a slideshow video, while I want the filename of each of the original images burned into the bottom right corner.  What my current state is: I made a script to fetch all .jpg files in the folder and make a ffmpeg-readable list and I know how to concat the images to a slideshow and everything works as intended. I also figured out how to use FFmpeg's drawtext to get a handsome filename stamp.   Now the problem: Currently FFmpeg grabs the last filename from the file list (for example IMG_9935.jpg) and burns it into the entire video. But what I want to happen is, that it changes with each 'new' image - just like a timecode would change during the course of the video.  Is any of this possible?  As a side note: "Why don't you burn the filename beforehand?" I'd like to keep it as flexible as possible. So if there's another way round, I'd like to go that way.  for i in *.jpg; do echo "file '$i'" &gt;&gt; files.txt; done  ffmpeg -r 1/3 -f concat -safe 0 -i files.txt -vf "eq=text=$(echo $i | rev | cut -d / -f 1 | rev): fontcolor=0x808080: fontsize=14: x=w-tw- 10:y=h-th-10" -c libx264 filename.mp4
115390
So here is what i want to pull : mmcblk0 whith it's size 15.7 GB.  C:\adb&gt;adb shell shell@android:/ $ su su shell@android:/ # fdisk -l /dev/block/mmcblk0 fdisk -l /dev/block/mmcblk0  Disk /dev/block/mmcblk0: 15.7 GB, 15758000128 bytes 1 heads, 16 sectors/track, 1923584 cylinders Units = cylinders of 16 * 512 = 8192 bytes   This is what I tried:  C:\adb&gt;adb shell su busybox cat /dev/block/mmcblk0 &gt; C:\1.bin   I only have 1KB output with content inside said "unknown id". Also tried with pull but seems also doesn't work.  What should I do to get this 15.7 GB mmcblk0  ?
41107
I have a bunch of video files which I would like to segregate based on file size I have decided.  Example:  Folder BB has 15 files of various file size.  I have sub folder set as:   less than 100 MB     -- folder A 100 MB to 500 MB     -- folder B more than 500 MB     -- folder C   So instead of manually doing it can it be done via Bash or a script.  I have a general idea that find command and a proper if else would work, but have no idea how to script it.  Anyway, a general programming frame would be:  float _size=[file_size]; // Reads the file size  if(_size&lt;100)    // File size is less than 100 MB   {  exec mv [file] /A/* ; // Move to folder A } else if(_size&gt;500) // File size is greater than 500 MB   {  exec mv [file] /C/* ; // Move to folder C } else if((_size&lt;=500)||(_size&gt;=100)) //file size is between 100 to 500   {  exec mv [file] /B/* ; // Move to folder C} else   {print("file error");}   So I hope it is easy to do. The above was just a general idea I would have done.
93569
I'm searching for an simple shell script to mv all folders in /var/www/uploads/ that containing Math or Physics in the name to /mnt/Backup/.