0

I have a script that will concat and rename the video files in a folder which I have pieced together using tips from StackExchange.

#!/bin/bash

ls -d $PWD/* >> file.txt sed -i "s/^|$/'/g" file.txt sed -i -e 's_.file &' file.txt ffmpeg -f concat -safe 0 -i file.txt -c copy ${PWD##/}.mp4

I would like to run this recursively, which would seem to involve using the find command, but I am a little wary of messing this up and losing a load of data.

Any help would be appreciated.

AKDub
  • 11
  • 1
    I guess it would help if you provide an example directory hierarchy and explain what the result is supposed to be (i.e. what exactly the ffmpeg call(s) shall look like). However, you need only one sed call: sed "s/.*/file '&'/" And you should use quotes: ls -d "$PWD"/*, "${PWD##*/}".mp4 – Hauke Laging Nov 28 '21 at 12:36
  • 2
    If you want manual checks to make sure nothing is messed up, I suggest using two steps: Replace the ls with find, and do the two sed as first step. Then manually inspect file.txt. Finally run ffmpeg on file.txt if the manual inspection is ok. – dirkt Nov 28 '21 at 14:00
  • also, copy a small subset of your directory hierarchy to another directory and work on that. if you mess it up, just delete the mess and copy the subset again. alternatively, write your output files to a different directory - again, delete if it fails, fix any bugs in your script, and run again. As a general rule: when doing anything potentially destructive, NEVER work on your only copy of the data. At the very least, make a backup so you can restore it in case of something going wrong. – cas Nov 29 '21 at 03:07

0 Answers0