Shell Script for enter folders and join file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script for enter folders and join file
# 1  
Old 09-16-2014
Shell Script for enter folders and join file

Hello everyone.

I have a dlink cam that save recordings splitted for hours. Each hour folder contain a lot of small avi files.

Repository has the following directories structure:

\_20140101/
\_ 01
\_a.avi
\_b.avi
\_ 02
\_c.avi
\_d.avi
\_20140101/
\_ 01
\_e.avi
\_f.avi
\_ 02
\_g.avi
\_h.avi

I need to enter each "day" directory and merge the "hours" avi files.

Command to merge is the following:

avimerge -o test.avi -i *.avi

My final goal is:

\_20140101/
\_ a+b+c+d.avi (concatenating of all avi files)
\_20140102/
\_ e+f+g+h.avi (concatenating of all avi files)

Other singles files and directory could be deleted after work.

Can anyone help me?
Ty
# 2  
Old 09-16-2014
Hello setterx,

Kindly use code tags as per forum rules while putting codes and commands in posts. Following may help you, but it is applicable for the given input. Kindly let us know if this helps as a starting point.

Code:
awk -vs1="\\\_" '($0 ~ /\_2014/) {value=$0;set++;} set{if($0 ~ /^\\\_[a-z]/){a=1;v=v?v OFS $0:$0}} {if(set>1 && a){gsub(/\\\_/,"+",v);gsub(/.avi|[[:space:]]|^+/,X,v);print value ORS s1 v".avi";v="";a="";set=1}} END{gsub(/\\\_/,"+",v);gsub(/.avi|[[:space:]]|^+/,X,v);print value ORS s1 v".avi"}' input_file

Output will be as follows.

Code:
\_20140101/
\_a+b+c+d.avi
\_20140101/
\_e+f+g+h.avi


Thanks,
R. Singh
# 3  
Old 09-16-2014
Your posted directory structure will not yield your desired output.

Anyhow, try sth. like (untested)
Code:
for i in \_201401*
  do cd $i
     avimerge -o test.avi -i */*.avi
#    delete files ad libitum
     cd ..
  done

No error checking nor e.g. directory test included yet...
# 4  
Old 09-17-2014
Thank you!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Loop logic, enter into respective IF as per enter input file name

have three big data file, however I just need to see the mentioned below one line form the all the file which has SERVER_CONNECTION Value File 1 export SERVER_CONNECTION=//dvlna002:10001/SmartServer File2 export SERVER_CONNECTION=///SmartServer File3 export... (1 Reply)
Discussion started by: Nsharma3006
1 Replies

2. Shell Programming and Scripting

Shell Script to Enter a Directory (Folder Name Contains Spaces)

I am writing a shell script to cd to a folder. folder name is "October Scripts" I am currently storing the name of folder in a shell variable as so path="October\ Scripts/". If I do cd $path I receive the error bash: cd: October\: No such file or directory What am I doing wrong? Kindly... (3 Replies)
Discussion started by: anand2308
3 Replies

3. Shell Programming and Scripting

fixperms on folders in shell script

Hi, I am using fixperms command to change permissions of diretories in my script, i have to change 3 directories permissions one by one using fixperms. i tried the below code code: exec DIR1/fixperms -rRy DIR1 exec DIR2/fixperms -rRy DIR2 exec DIR3/fixperms -rRy DIR3 but this is... (4 Replies)
Discussion started by: sreelu
4 Replies

4. Shell Programming and Scripting

Simulating enter key via shell script

How to simulate enter key via shell script (2 Replies)
Discussion started by: proactiveaditya
2 Replies

5. Shell Programming and Scripting

Shell script to check if any file exists in 4 folders

Hi All, working on AIX 5.3. Requirement is: Shell script in ksh to check if any file exists in 4 folders as below: 1. /FILE/INB/INT1 2. /FILE/INB/INT2 3. /FILE/INB/INT3 4. /FILE/INB/INT4 Thanks a lot for your time! a1_win. (3 Replies)
Discussion started by: a1_win
3 Replies

6. Shell Programming and Scripting

How to catch ENTER key inside the shell script?

Hi, I have a script in which i have to ask user to press the ENTER key to proceed further. can you please help me how can i achive this in my scripting? echo "All the executables builded Successfully " echo " Press Enter to Go Back to the Main Menu" ... (2 Replies)
Discussion started by: plaban.rout
2 Replies

7. Shell Programming and Scripting

Enter Crtl+U character in shell script

hi I have some program which accepts "Crtl+U" input, Now i want to run it thorugh my written script ...all other inputs are accepted but how to supply this input. I am supplying input parameters to the program named EX as below. ================================= main.sh . . EX<<EOF... (3 Replies)
Discussion started by: ashish_uiit
3 Replies

8. UNIX for Dummies Questions & Answers

Shell Script using Join, empty field help!

Deleted#### (1 Reply)
Discussion started by: tibbyuk
1 Replies

9. Shell Programming and Scripting

writing Enter key inside in shell script

for automating telnet using shell script..... as we enter alphabetic characters inside shell script...how can we do the same for the enter key......Is there any character for the enter key so the enter key need not be pressed manually...... (3 Replies)
Discussion started by: bishweshwar
3 Replies

10. UNIX for Advanced & Expert Users

using enter key in shell script

without pressing the enter key ..manually... how can we read the enter key ..from the shell script..so that the script termintes automatically. eg: telnet a.b.c.d xxxx now " how to read the enter key" tho terminate the script (1 Reply)
Discussion started by: bishweshwar
1 Replies
Login or Register to Ask a Question