views:

107

answers:

1

I am an ETL developer and I deal with a lot of data that needs to be processed from one form to the other before it can be loaded into tables. Therefore, most of the scripts that I work with, at some point, have to move a file from one place to the other. We are a windows shop. I was wondering if there was a way to see how much time a move takes when I am using the move function in Perl. If I need to call a windows command through system that will give me this option, then I am ok to use that as well. Is there anything in Perl or windows command line that will tell me the progress of the file transfer?

Thanks!

+7  A: 

You can use the Win32::FileOp package from cpan.

Here's a relevant excerpt:

CopyConfirm

 CopyConfirm ($FileName => $FileOrDirectoryName [, ...])
 CopyConfirm (\@FileNames => $DirectoryName [, ...] )
 CopyConfirm (\@FileNames => \@FileOrDirectoryNames [, ...])

Copies the specified files. In case of a collision, shows a confirmation dialog. Shows progress dialogs.

Returns true if successful.

MoveConfirm

Moves the specified files. Parameters as CopyConfirm

A command line alternative would be Term::ProgressBar, which is also a lot more flexible, but somewhat harder to set up. You would have to do something like: get the original file's size, then start the copy and poll the new file's size (from a child process) to give updates to the progress bar.

Zenshai
Thanks. This is definitely what I was looking for. Now I need some spare time to implement this on all the scripts I have.
tundal45