in reply to Re: encode files to utf-16 and then move
in thread encode files to utf-16 and then move
#!/usr/bin/perl use warnings; use strict; my $srcdir = "C:\\ROOT_DIR\\test1\\"; my $dest = "C:\\ROOT_DIR\\test2\\"; my (@files); for (;;) { opendir(DIR, $srcdir) or die "Can't open $srcdir: $!"; @files = grep {!/^\.+$/} readdir(DIR); close(DIR); if (!@files) { print "done.\n\n"; last; } my $file = $files[0]; open(my $src_fh, "<:raw:perlio:encoding(UTF-8)", "$srcdir$file") or die("Can't open \"$srcdir$file\": $!\n"); open(my $dst_fh, ">:raw:perlio:encoding(UTF-16)", "$dest$file") or die("Can't open \"$dest$file\": $!\n"); print $dst_fh $_ while <$src_fh>; unlink($src_fh); sleep 1; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: encode files to utf-16 and then move
by ikegami (Patriarch) on May 11, 2009 at 14:11 UTC | |
|
Re^3: encode files to utf-16 and then move
by Anonymous Monk on May 11, 2009 at 13:19 UTC |