tags:

views:

118

answers:

1

I have a parent_folder_1 and many sub folders inside that. I also have parent_folder_2 and many sub folders inside that.

Sub folders contains .d files.

I have to get the number of parent_folders that the user wants to compare.

For example:

"How many parent_folders do you want to compare?"

If the user inputs 4, then the script should ask for paths of all the four parent_folders.

And, in one parent folder, inside one sub_folder, there is another folder called d folder which contains .d files.

I have to compare each .d file in all the four parent folders and have to put the results in an Excel spreadsheet as to which .d files are present in which parent folders.

If xxx.d sf present in parent folder1 and parent folder3, then the output should be:

xxx.d  parent folder1 #this space is for parent folder2 if present# parentfolder3
+3  A: 

This is the idea:

  • Use File::Find to traverse directories, sub-directories and files.
  • In wanted(), check for:

    -f $File::Find::name && $File::Find::name =~ /^.+\.d$/

  • If the above condition evaluates to false, return; else, compare the files and populate the spreadsheet.

Alan Haggai Alavi