Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Batch join .001 files?
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Batch join .001 files?

sonicsonic Veteran
edited May 2013 in Help

I have tons of .avi.001 in my homemade clips folder. How to batch join them?

I try
cat a.avi.* > a.avi
It works fine but it takes much time to do 1 by 1.

Example: i have

a.avi.001 a.avi.002 a.avi.003

b.avi001 b.avi.002 b.avi.003

c.avi.001 c.avi.002 c.avi.003

How to join

a.avi.001 a.avi.002 a.avi.003 to a.avi

b.avi001 b.avi.002 b.avi.003 to b.avi

c.avi.001 c.avi.002 c.avi.003 to c.avi

with 1 command or bash. I dont want to type each command for each movie :(

http://i.imgur.com/dMP3FQq.jpg

Comments

  • Mon5t3rMon5t3r Member

    hjsplit?

  • sonicsonic Veteran

    Mon5t3r said: hjsplit?

    hjsplit for linux? can it help me bactch join in one command?

  • sonicsonic Veteran

    Did you read my first post?
    I know how to split and merge file. cat, hjsplit,... can do it.

    But what i want to know is how to batch join files.

  • Mon5t3rMon5t3r Member

    @sonic said: can it help me bactch join in one command?

    i can't remember, sorry. And i was using it only for merging two files max.

  • tehdantehdan Member

    you can do this in 2 stages, which is best if you want to be cautious.

    First, you need a list of the files you're trying to recreate, get this with -

    ls | sed 's/\.[0-9][0-9][0-9]$//' | sort | uniq > .filelist
    

    this should take a list of all files, chop the .nnn extensions off and find the unique values - so the file '.filelist' should contain a list of your target files - check it carefully. I've made .filelist a hidden file so it doesn't get listed in the file itself. You should get something like -

    a.avi
    b.avi
    c.avi
    

    Alternatively, you could produce this file by hand. Now use a for loop with your original cat command -

    for f in `cat .filelist` ; do
      cat ${f}.[0-9][0-9][0-9] > ${f}.avi
      echo -n .
    done
    

    the echo -n . line is optional, but its a quick way to see some progress - you'll get a . for each complete concatenation.

    Its possible that if your source files aren't named strictly according to your convention that this will screw up - check your results before you delete the source files :)

    If you're very brave, you can stick the first command in place of cat .filelist in the 2nd command.

  • t3k9t3k9 Member
    #!/bin/bash
    
    for i in *avi.001; do
            B=$(basename $i .001)
            cat $(ls $B.* | xargs) > $B
    done
    
    Thanked by 1fLoo
Sign In or Register to comment.