[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Unix-ify File Names



* Masatran, R. Deepak <masatran@research.iiit.ac.in> 2007-04-17
> Since I frequently receive files from Microsoft Windows users, is there any
> utility to unix-ify file names, that is, use lower case exclusively, use
> hyphen as separator, etc.?

I wrote the script below just now. Kindly give comments. This script is also
available at <http://research.iiit.ac.in/~masatran/scripts/unixify>.

#!/usr/bin/perl
# Unix-ify name of file given as argument.
# For multiple files, use along with the "find" program of Unix.
# Supports Unicode file names
# Correctly handles dangerous characters in file names.
# How to get confirmation before over-writing a file, without sacrificing portability?

use strict;
use warnings;
use utf8;

my $name_original = shift;
my $name_lowercase = lc $name_original;
my $name_unix = join("-" => split(/\W/ => $name_lowercase));
rename $name_original => $name_unix;

-- 
Masatran, R. Deepak <http://research.iiit.ac.in/~masatran/>

Attachment: pgpEWWUDZXvTX.pgp
Description: PGP signature


Reply to: