RFC: fixname v 0.3
mulander
created: 2006-01-16 16:13:28
Hello fellow Monks!
Yeasterday I had to scim through my old drive wich prevoisly was something that 'Windows' called it's home for a long time.

I am using linux for a long time now and I don't have to tell you how unfriendly it is to cd into a directory containing many spaces and being half upper case or even all upper case... and those very long names... I thought that something has to be done about it. And I asked myself why couldn't Perl help me at it?


So I set down and wrote a simple script that could make those names more friendly to me. I added a few features and now I would like to ask You for a opinion.


Here is the --help from this script:
Usage: ./fixname.pl options target

target          either a file or a directory

This script changes file names to more user friendly ones

Options:
-h, --help              display this help screen
-V, --version           display version information
-S, --sub-space=X       substitute spaces in the file name with a specified char  
acter
-s, --strip             remove all spaces from the file name
-l, --lower             transfer all upper case letters in the filename into low  
er case letters
-u, --upper             transfer all lower case letters in the filename into upp  
er case letters
-v, --verbose           give verbose informations use multiple times to get even  
 more verbose output
-d, --dir-only          only change directory names
-f, --file-only         only change file names
-F, --force             the script will change file names even if the destinatio  
n name already exists
-t, --trim=X            trims the filename to given length ( must be more than 0  
 length )


I have also started to write a .pod documentation for the script, my first one indeed so please fell free to criticise.

You can get both the script source and pod doc in tar.gz format from http://kewlnet.int.pl/~karql/fixname.tar.gz

What are my concerns right now?
Well the most irritating thing is fat type drives, because FILE and file are treated the same so --lower and --upper function by themselv won't change the filename ( it seems to work if used with something that changes characters in the file or its lenght like --trim or --subspace )
I was wondering if You could point me in a direction to solve this problem.

Another thing is about the features, those implemented are beacuse I found them useful, I would like to know what is useful for the most of us, is this script even worth further development?

I was thinking on adding --regex to allow direct control over file changing, but the question is should I give control over the whole regexp and pass it as an eval ? or take only the args double-check them and pass it into my preset regular expression? Should I allow the regex to modifie the file extension ( if it exists ? ); or should I forget about implementing regexps at all ?

Also I am wondering about the code, how do you find it? Is it passable ? In the means of efficiency, and maybe style? If not on what parts should I focus?

There is a second reason for this post, I thougth that maybe someone will find this useful like I did.


I am sorry for my grammar mistakes as english is not my native language.
Re: RFC: fixname v 0.3
created: 2006-01-16 17:08:45
I don't have any annoying directories on my linux machine! I don't create directories with spaces in the directory name. My linux installation didn't come with any spaces in the directory names. In general, the names are all lowercase, or at worse, mixed case. I don't have any problem with how my directories are named in the first place.

You do know about filename (and directory) name completion features in your shell, right? It almost never matters exactly what the full file or directory name is, just that the first few letters are unique within the directory listing. Assuming that you structure your directories that way, file globbing or name completion make typing fairly minimal.

In short, this module sounds a lot like a solution in search of a problem.

Re^2: RFC: fixname v 0.3
created: 2006-01-17 04:23:45
I don't have any annoying directories on my linux machine! I don't create directories with spaces in the directory name.

Me too! But what's nice is that in those rare situations in which I have to deal with (supposed to be) annoying filenames, I can do that effortlessly. I can have a file with a "\n" in it's name and the shell will expand it just as fine as any other one. Well... and if the "\n" is the first charachter? Whatever, when I'm totally lost -and it happens very rarely- mc or a tool like that comes to the rescue!

Re: RFC: fixname v 0.3
created: 2006-01-17 10:08:13
I think you made a worthy programming exercise, and ESPECIALLY like your --help text, and pooh! on the AnonyMonk who dissed you. So what if TMTOWTDI??? I will add one suggestion to [blazar]'s, which is:
perl -e 'rename "./" . "\nbraindead\tname", "sensible_name"'
which helps catch those pesky '-' at the beginning. :D

Don Wilde
"There's more than one level to any answer."
Re: RFC: fixname v 0.3
created: 2006-01-18 17:07:47

I tend to be of the opinion that software should be expected to do the right thing when dealing with files with spaces in them. That's utterly common in /home/*. I'd consider it a gross insult to have my tools insist that I not use spaces or other legal characters in my file or directory names.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

perlmonks.org content © perlmonks.org and Anonymous Monk, blazar, diotalevi, dwildesnl, mulander, parv

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03