473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

seraching binary files by their version

hi all,

suppose I have a directory with lots of levels of subdirectories within that. any of the sub directory may contain .exe and .dll files. different directories may contain dlls and exe's with same name but they differ in their versions. now i want to write a perl script that can search a dll or exe with a given name having a particular version. for example..

lets there is a directory "root" with 4 subdir a,b,c,d. all of them contain a dll file named "myfile.dll", the versions are say as follows

directory dll name version

a myfile.dll 1.1.0

b -do- 1.1.1

c - do- 1.1.2

d -do- 1.1.3



now I give as an input to my script "myfile.dll" and "1.1.2" then it shoud return me the myfile.dll file of directory "C"

I hope this is clear to u all..

waiting for your replies

thanks.
Mar 12 '08 #1
1 1045
use the dos command to find the version of the dll or exe file in the foreach loop
with the the perl system command or exec command.

Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
  3. use File::Find;
  4. use File::Basename;
  5. use File::Spec::Unix;
  6.  
  7. my $top_dir = $ARGV[0];
  8. my $dir_path = File::Spec->rel2abs($top_dir);
  9. my @file_list = ();
  10. my @all_file = Get_Dirs_Files($dir_path);
  11. foreach my $item (@all_file) { 
  12.   push(@file_list,"$item") if($item =~ m/.*\.dll$|.*\.exe$/);
  13. }
  14.  
  15. @file_list = map{"$dir_path/"."$_"} @file_list;
  16.  
  17. foreach my $my_file (@file_list) {
  18.   my ($file_name,$dir,$file_type) = fileparse($my_file,qr"\..*");
  19.   print "$my_file\n";
  20.   #/use the system command to find out the version of the dll file here/
  21. }
  22.  
  23. #------------------------------------------------------
  24. # Get all the files from the directory recursively 
  25. #------------------------------------------------------
  26.  
  27. sub Get_Dirs_Files {
  28.   my $cur_folder = shift;
  29.   my @all;
  30.   chdir($cur_folder) or die("Cannot access folder $cur_folder");
  31.   my @both = glob("*");
  32.   my @folders;
  33.   foreach my $item (@both) {
  34.     if(-d $item) { 
  35.       push(@folders,"$item");
  36.     } 
  37.     else { 
  38.       push(@all,"$item");
  39.     }
  40.   }
  41.  
  42.   foreach my $this_folder (@folders) {
  43.     push(@all,"$this_folder/");
  44.  
  45.     my $full_path = "$cur_folder/$this_folder";
  46.     my @deep_items = Get_Dirs_Files($full_path); # :RECURSION:
  47.     foreach my $item (@deep_items) {
  48.       push(@all,"$this_folder/$item");
  49.     }
  50.   }
  51.   return @all;
  52. }
  53.  
  54.  
-Manimaran
Mar 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

21
by: Sami Viitanen | last post by:
Hello, How can I check if a file is binary or text? There was some easy way but I forgot it.. Thanks in adv.
27
by: Eric | last post by:
Assume that disk space is not an issue (the files will be small < 5k in general for the purpose of storing preferences) Assume that transportation to another OS may never occur. Are there...
6
by: alice | last post by:
hi all, Can anybody please tell the advantages which the binary files offers over the character files. Thanks, Alice walls
6
by: | last post by:
Hi all, is there a better way to stream binary data stored in a table in sql 2005 to a browser in .net 2.0? Or is the code same as in .net 1.1? We noticed that in certain heavy load scenarios,...
10
by: Fabuloussites | last post by:
I'm considering deploying an application that will us an IP address locaiton database provided by Ip2location.com... http://www.ip2location.net/ip2location-dotnet-component.aspx their .net...
6
by: Caveman | last post by:
Hello, My company recently purchased source code from a company we have been doing business with for several years. In the past, they have done all of the development for this product. Their...
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
4
by: Pedro Leite | last post by:
Good Afternoon. the code below is properly retreiving binary data from a database and saving it. but instead of saving at client machine is saving at the server machine. what is wrong with my...
11
by: itdevries | last post by:
Hi, I'm trying to convert some char data I read from a binary file (using ifstream) to a float type. I've managed to convert the int types but now I need to do the float types as well but it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.