For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > April 2005 > mkdir? system? split?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author mkdir? system? split?
Thomas W Bliss

2005-04-19, 3:56 pm

Hello all, I am new to this list and appreciate all of your help.

I am trying to write a Windows perl script to move files from Windows
volume A to Windows volume B and keep the directory structure. I tried
to use mkdir but it will only create one directory deep.

I am reading a file that contains data like this:

\\server\share\dir1\dir2\...\file1.txt

So far I have been successful in opening and reading the file. I also am
passing 3 arguments from the command line which I have captured into
variables (-s source of the data file above, -d destination volume where
is it to be moved to, and -l a log file in which we will capture what
files have been moved.)

Here is what I need yet:

1. I need to parse each line in the file for just the directory
structure (I assume split is what I want but I have not addressed this
yet) and get just the \dir1\dir2 so I can recreate it.
2. Create the directory structure on the new volume from the -d cmd line
arg
2a. If I use mkdir within perl then I need to parse the complete
directory list and then loop through each dir to create it on the -d
volume.
2b. I could call the DOS MD and pass it the complete variable
structure of the combine -d + parsed dir from the file. I tried some
testing but could not seem to pass the system () any variable data.
3. Then I can use the move within perl to move the file with the
combined -s and -d+ new parsed dir\file from the file.

Any help on the above steps would be greatly appreciated. If you need to
see what I have I can send it out but it is not much right now. Thank
you in advance for your help.
Tom Bliss, Principal Consultant
Computer Associates TS, SNIA SCSE
Office Phone: 513-229-2366
e-mail: Thomas.Bliss@ca.com <mailto:Thomas.Bliss@ca.com>




JupiterHost.Net

2005-04-19, 3:56 pm



Bliss, Thomas W wrote:
> Hello all, I am new to this list and appreciate all of your help.
>
> I am trying to write a Windows perl script to move files from Windows
> volume A to Windows volume B and keep the directory structure. I tried
> to use mkdir but it will only create one directory deep.


I'm not sure all those steps below are necessary. Have you looked at
File::Copy::Recursive
?

http://search.cpan.org/~dmuey/File-...06/Recursive.pm
Offer Kaye

2005-04-19, 8:55 pm

On 4/19/05, JupiterHost.Net wrote:
>=20
> I'm not sure all those steps below are necessary. Have you looked at
> File::Copy::Recursive
> ?
>=20
> http://search.cpan.org/~dmuey/File-...06/Recursive.pm
>=20


There's also the "mkpath" function from File::Path, that can be used
to create a directory tree:
http://perldoc.perl.org/File/Path.html

--=20
Offer Kaye
JupiterHost.Net

2005-04-20, 3:56 pm



Bliss, Thomas W wrote:

> I looks interesting. Thanks.


np, please don't top post and always reply to the list and not an
individual :)

> The learning curve is hell in this language because there is 300 ways to
> do anything.


actually that makes it easier to use as you will likley see later :)
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com