473,466 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

copying files in a dir

48 New Member
Hi all,
I have some files stored in an array say my array I have to read each file from the array and if the files ends with .raz I need to copy.

I need to copy the file from /home/kriz to /home/kriz/temp.iam working in unix environment ,as Iam new to perl can anyone say me how to check if it is a file and then how to check to ends with raz...

thanks
May 23 '07 #1
3 1162
KevinADC
4,059 Recognized Expert Specialist
Expand|Select|Wrap|Line Numbers
  1. if ($foo =~ /\.raz$/) {
  2.     # do something
  3. }
  4.  
May 23 '07 #2
savanm
85 New Member
This is another idea

Store the .raz file in ur Array...

Expand|Select|Wrap|Line Numbers
  1. my $path = getcw();
  2. $path =~ s|\\|/|sg;
  3. opendir(DIR, $path) or die "Can't opendir $path: $!";
  4. my @raz = grep {/\.raz/} readdir(DIR); # Here U Get only .raz file in ur array
  5.  
Otherwise Check like this
Suppose ur Array name is @foo

Expand|Select|Wrap|Line Numbers
  1. foreach $foo (@foo) {
  2.     if ($foo=~/\.raz$/) {
  3.         # then do wt ever u want
  4.     }
  5. }
  6.  
Navas
May 23 '07 #3
savanm
85 New Member
Expand|Select|Wrap|Line Numbers
  1. use File::Copy;
  2. use Cwd;
  3.  
  4. my $path = getcwd();
  5. $path =~ s|\\|/|sg;
  6. opendir(DIR,$path) or die "Can't opendir $path: $!";
  7. my @raz=grep {/\.raz/} readdir(DIR);
  8.  
  9. foreach $raz (@raz) {
  10.     print "$raz\n";
  11.     $new = "$path/new";
  12.     copy("$path/$raz",$new);
  13. }
  14. closedir(DIR);
  15.  

Hi the above code is a sample code for copying the files from the current path(suppose c:/temp/) to (c:/temp/new)...

Navas.M
May 23 '07 #4

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

Similar topics

3
by: Robert Tarantino | last post by:
Hello, I am trying to find a way to create a scheduled task or service that will copy my local profile folders under "Documents and settings" to a network drive. This would allow me to restore...
4
by: Alex Vinokur | last post by:
Copying files : input to output =============================== C/C++ Performance Tests ======================= Using C/C++ Program Perfometer http://sourceforge.net/projects/cpp-perfometer...
0
by: Dan | last post by:
We debug a VB.Net App that uses compact framework to a DAP Windows CE.Net device. When I debug I would like to only have the EXE copied down. Right now it copies any referrences as well and...
2
by: | last post by:
Hello, I have a program that starts a new thread to backup files from a computer over the network to our server. The problem is when it is copying the files you can hardly navigate around in...
10
by: Martin Ho | last post by:
I am running into one really big problem. I wrote a script in vb.net to make a copy of folders and subfolder to another destination: - in 'from.txt' I specify which folders to copy - in...
4
by: zMisc | last post by:
Is it possible to copy a table from one schema to another schema by just copying the frm file to the directory for the new schema? What is the best way to create a new database with all the...
6
by: Jim Heavey | last post by:
I have written a little application which copies files from one location to another location. Before it copies the file, it ensure the directory for both the from and to locations is valid. It...
2
by: Edhy Rijo [Progytech] | last post by:
Hi All, I am learning VB.NET and building small application that will do the following: 1.. Copy all files from a DVD to a specific folder in the hard drive and overwrite all files always. The...
6
by: kimiraikkonen | last post by:
Hi, I use system.io.file class to copy files but i have a difficulty about implementing a basic / XP-like progress bar indicator during copying process. My code is this with no progress bar,...
13
by: writeson | last post by:
Hi all, I'm writing some code that monitors a directory for the appearance of files from a workflow. When those files appear I write a command file to a device that tells the device how 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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.