Showing posts from October, 2011

Using perl to extract files from large directory structure

When I work on Windows I use Activesite Active Perl to do some stuff. Recently I had to copy about 60 files from large directory structure to a new place (about 800 files in nasty directory structure). It was rather boring stuff to do, so I used perl to finish job because it would be pretty easy task to do using hashes (I had names of files given in text file). Unfortunately I had some problems on completion of job, because there was a problem with encoding of file path name on Windows.Below I provide simple script demonstration how to handle national characters in path using perl on Windows.#!/usr/bin/perl use strict; use warnings; use utf8; use Encoding; # Win32::Codepage::Simple is available in ActiveState Perl use Win32::Codepage::Simple qw(get_codepage get_acp); use File::Find; use File::Copy; use File::Path; use File::Basename; binmode STDOUT, ":utf8"; binmode STDERR, ":utf8"; my $dir = "./copy_from_here/"; my $dest = "./copy_here/…