in reply to Re: Validate windows filenames.
in thread Validate windows filenames.

Actually my code did check for an error but the module that I used did not return an error. And even worse, instead of not moving the file and leaving it were it was, it just deleted it or moved it into oblivion.So even if I caught the error what was I to do:

die "You are gonna hate life now. The file move failed and the source file has been deleted. Goodbye.\n";

But thanks for the obvious....

other peoples modules are great, untill they dont work as advertised.

Not pointing fingers... I THINK the module should have handled this situation better, however I failed to validate the filename before trying to move the file.. Maybee the OS did not return an error to the module. who knows. This was one of my earlier scripts and worked great for a long time ( many years ) till it found and MP3 TAG with invalid characters in it.

So back to the original question.... How do you validate filenames???

Replies are listed 'Best First'.
Re^3: Validate windows filenames.
by jbrugger (Parson) on Jul 14, 2005 at 07:48 UTC
    If you try to copy the file in stead of moving / renaming? Check if success, then delete the original.

    "We all agree on the necessity of compromise. We just can't agree on when it's necessary to compromise." - Larry Wall.

      Once I discovered the error, I changed the code to both validate the filename and do a copy / delete. However having to jump through a copy / delete 2 - process step kind of defeats the purpose of having a move function....

      Thanks for the reply.. However, Im not looking for a solution to deal with the moving of the file. I only mentioned that as background to why validating windows filename is important.

      My Questions are: (1) Do fellow perlmonks routinely validate filenames? If so, how do you do it? (2) Any inherit problems with how my routines deal with validating/sanitizing windows filenames??

      zzSPECTREz