comparing multiple files in multiple subfolders


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting comparing multiple files in multiple subfolders
# 1  
Old 04-14-2009
comparing multiple files in multiple subfolders

Hello,
I am having a bit of hard time to get my head around this one. I really hope someone is out there to help me out!
Background of my code:
I am doing some automation where I am verifying multiple files in multiple sub folders and if they are all identical, I would echo a line with my test case title and stating it passed. If anything is not same I echo fail to a file.

Folder structure would look like this:
Folder
Folder1
Test1.mp3
Folder2
Folder2.1
Test2.mp3
Test3.mp3

I am somewhat new to Apple, so please pardon me for my ignorance.

Goal:
I have a list of expected file that I am comparing with (which also has same folder structure and same files). Once the media are transferred to the external SD card, I want to verify if all my songs and playlist are transferred properly.


Below is my code as of now and its not really working out well.

Code:
Export SD=Test
Export path="~/Desktop/Result.txt”
export Actual="/Volumes/$SD/BlackBerry/music/Media Sync/"
export Expected="~/Desktop/Automation/Test_Cases/Supported_Unsupported/Expected/Media Sync"

# I do this such that no other unwanted files are there.  Apple seems to create those .DS files and BlackBerry. 

find "$Expected" . -name "*.DS*" -type f -exec rm -rf {} \;
find "$Actual" . -name "*.DS*" -type f -exec rm -rf {} \;
find "$Actual" . -name "*.dat" -type f -exec rm -rf {} \;
find "$Expected" . -name "*.dat" -type f -exec rm -rf {} \;

#echo "$Actual"
#echo "$Expected"
#diff "$Actual" "$Expected" 
# I do not know if it will actually go to subfolders and compare or just the root folder.  
diff "$Actual" "$Expected" &> /dev/null
if [ $? -eq 0 ]         
then 


echo Test Case for synchronizing supported & unsupported playlist - Passed >> "$path"

echo - passed
else

echo Test Case for synchronizing supported & unsupported playlist - Failed >> "$path"

echo - failed 
fi

open "$path"

Last edited by vidyadhar85; 04-14-2009 at 04:52 PM.. Reason: code tag added
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed parser behaving strange on replacing multiple words in multiple files

I have 4000 files like $cat clus_grp_seq10_g.phy 18 1002 anig_OJJ65951_1 ATGGTTTCGCAGCGTGATAGAGAATTGTTTAGGGATGATATTCGCTCGCGAGGAACGAAGCTCAATGCTGCCGAGCGCGAGAGTCTGCTAAGGCCATATCTGCCAGATCCGTCTGACCTTCCACGCAGGCCACTTCAGCGGCGCAAGAAGGTTCCTCG aver_OOF92921_1 ... (1 Reply)
Discussion started by: sammy777888
1 Replies

2. Shell Programming and Scripting

Comparing multiple files

I want to develop one unix script that will first match the multiple files on one server say A with multiple files on another server say B and copy those to server A. After that need to compare the contents of these 2 set of multiple files on different location on same server and generate the... (4 Replies)
Discussion started by: Charnjeet Singh
4 Replies

3. Shell Programming and Scripting

Removing carriage returns from multiple lines in multiple files of different number of columns

Hello Gurus, I have a multiple pipe separated files which have records going over multiple Lines. End of line separator is \n and records going over multiple lines have <CR> as separator. below is example from one file. 1|ABC DEF|100|10 2|PQ RS T|200|20 3| UVWXYZ|300|30 4| GHIJKL|400|40... (7 Replies)
Discussion started by: dJHa
7 Replies

4. Shell Programming and Scripting

Comparing multiple network files (edge lists)

I want to compare 4 edge-lists to basically see if an edge is present in all 4 networks. The issue is that an edge A-B in one file can be present as B-A in another file. Example: Input 1: net1.txt A B 0.1 C D 0.65 D E 0.9 E A 0.7 Input 2: net2.txt A Z 0.1 C D 0.65 E D 0.9 E A... (1 Reply)
Discussion started by: Sanchari
1 Replies

5. UNIX for Advanced & Expert Users

Need help in comparing multiple columns from two files.

Hi all, I have two files as below. I need to compare field 2 of file 1 against field 1 of file 2 and field 5 of file 1 against filed 2 of file 2. If both matches , then create a result file 1 with first file data and if not matches , then create file with first fie data. Please help me in... (12 Replies)
Discussion started by: sivarajb
12 Replies

6. Shell Programming and Scripting

Create Multiple UNIX Files for Multiple SQL Rows output

Dear All, I am trying to write a Unix Script which fires a sql query. The output of the sql query gives multiple rows. Each row should be saved in a separate Unix File. The number of rows of sql output can be variable. I am able save all the rows in one file but in separate files. Any... (14 Replies)
Discussion started by: Rahul_Bhasin
14 Replies

7. Shell Programming and Scripting

awk arrays comparing multiple columns across two files.

Hi, I'm trying to use awk arrays to compare values across two files based on multiple columns. I've attempted to load file 2 into an array and compare with values in file 1, but success has been absent. If anyone has any suggestions (and I'm not even sure if my script so far is on the right lines)... (4 Replies)
Discussion started by: hubleo
4 Replies

8. UNIX for Dummies Questions & Answers

Comparing multiple fields from 2 files uing awk

Hi I have 2 files as below File 1 Chr Start End chr1 120 130 chr1 140 150 chr2 130 140 File2 Chr Start End Value chr1 121 128 ABC chr1 144 149 XYZ chr2 120 129 PQR I would like to compare these files using awk; specifically if column 1 of file1 is equal to column 1 of file2... (7 Replies)
Discussion started by: sshetty
7 Replies

9. UNIX for Dummies Questions & Answers

Using AWK: Extract data from multiple files and output to multiple new files

Hi, I'd like to process multiple files. For example: file1.txt file2.txt file3.txt Each file contains several lines of data. I want to extract a piece of data and output it to a new file. file1.txt ----> newfile1.txt file2.txt ----> newfile2.txt file3.txt ----> newfile3.txt Here is... (3 Replies)
Discussion started by: Liverpaul09
3 Replies

10. Shell Programming and Scripting

comparing multiple files

hi, quick question i have one file which join one file with reference one Looks like this: KB0000 KB207418 KB0001 KB244904 KB0002 KB215027 KB0003 KB215027 KB0004 KB215027 KB0005 KB204320 KB0006 KB207074 KB0007 KB215204 KB0008 KB223809 KB0009 KB236640 KB0010 KB244506 ....... (2 Replies)
Discussion started by: karla
2 Replies
Login or Register to Ask a Question