Long file name tool..OSX
Thread Starter
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
guys can you help me.
need to find a tool that can shorten loads (and i mean loads ) of long file names on a volume. Basically I have a Buffalo Terastation and it wont accept long file names coming from mac clients.
So if you can locate me a tool that can shorten/truncate in batch mode, then i would be externally grateful
need to find a tool that can shorten loads (and i mean loads ) of long file names on a volume. Basically I have a Buffalo Terastation and it wont accept long file names coming from mac clients.
So if you can locate me a tool that can shorten/truncate in batch mode, then i would be externally grateful
If you're using 10.4, then you could try automater. If not, then applescript would probably be the next best thing.
If you want to email me (markuswarren@gmail.com) with say 10 sample file names and what you'd like them truncated to, I could probably knock up a script to do it.
If you want to email me (markuswarren@gmail.com) with say 10 sample file names and what you'd like them truncated to, I could probably knock up a script to do it.
Thread Starter
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Originally Posted by Markus
You should have an email with an attached script waiting for you. It'll do files, but not folders, shout if you need it to do both.
top man
what i will do is do a trial run on some files, see how it works and if all good, then i will come back and see if i need the folder script.
do appreciate all this mate
Files and folders will take a bit more work than expected. Problem is if you rename a folder that contains items you were then going to search, you need to reset the search path to include the new folders name, otherwise it cannot find the folder.
I'll work on it over the weekend if I get a chance.
I'll work on it over the weekend if I get a chance.
Trending Topics
This should work anywhere you have a perl installed, OS X included. Use it like:
$ ./shorten <max filename length> <directory>
$ ./shorten 20 /path/to/some/dir
It won't change the top level dir name. It will deal with any duplicate filenames that may arise from the shortening of the file by changing the filename slightly (although the filename limit might be breached if there are too many duplicates in the same directory):
Oh, use this at your own risk. It will remove filename extensions
$ ./shorten <max filename length> <directory>
$ ./shorten 20 /path/to/some/dir
It won't change the top level dir name. It will deal with any duplicate filenames that may arise from the shortening of the file by changing the filename slightly (although the filename limit might be breached if there are too many duplicates in the same directory):
Code:
#!/usr/bin/perl
use strict;
use warnings;
use File::Find;
my $max_length = shift;
my $stuff = {};
finddepth(sub {
length > $max_length && do {
my $n = substr($_, 0, $max_length);
$n++ while (exists $stuff->{$File::Find::dir . "/$n"});
$stuff->{$File::Find::dir . "/$n"}++;
rename $_ => $n or die "[$_] $!\n";
};
}, shift);
Last edited by stevencotton; Jul 23, 2006 at 02:11 AM.
http://www.versiontracker.com/dyn/moreinfo/macosx/17205
Use this very regularly. Versatile, reliable, easy to use. Spot on
Use this very regularly. Versatile, reliable, easy to use. Spot on
Thread Starter
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Originally Posted by Markus
You should have an email with an attached script waiting for you. It'll do files, but not folders, shout if you need it to do both.
you have email..
Thread Starter
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Originally Posted by jowl
When you've perfected it with files and folders, I'd love a copy if I may. I have a bufallo Linkstation with the same issue.
Not a major problem at the moment though
Not a major problem at the moment though
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
Dec 28, 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
Nov 18, 2015 07:03 AM





