truncate file names (using perl's rename)

toyfactory toyfactory at xsmail.com
Wed May 11 06:12:03 UTC 2005


I'm sorry if this is not Ubuntu specific but...

I'm trying to figure out an easy way to truncate filenames to a specific
length while retaining the extension.  I've been playing with regular
expressions in Perl but, although I think I've figured out a way to do
it, I've not quite got it working properly from the command line.  In
the meantime I discovered there's a rename command included with Perl.
Can anyone save me an afternoon of unproductive Googling and head
scratching and just tell me how to do it?  For example:

using 'rename <complicated regex here> *.txt'

'this_filename_is_simply_too_long_for_my_liking.txt'

becomes

'this_filename.txt'

Cheers,

Nick




More information about the ubuntu-users mailing list