Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Long file name tool..OSX

Thread Tools
 
Search this Thread
 
Old Jul 21, 2006 | 04:12 PM
  #1  
SwissTony's Avatar
SwissTony
Thread Starter
Scooby Regular
20 Year Member
iTrader: (19)
 
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Default Long file name tool..OSX

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
Reply
Old Jul 21, 2006 | 04:52 PM
  #2  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
Default

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.
Reply
Old Jul 21, 2006 | 04:57 PM
  #3  
SwissTony's Avatar
SwissTony
Thread Starter
Scooby Regular
20 Year Member
iTrader: (19)
 
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Default

markus

cheers big ears

will sort this out when i come back into the office.
stay tuned sir and thanks
Reply
Old Jul 21, 2006 | 09:28 PM
  #4  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
Default

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.
Reply
Old Jul 21, 2006 | 10:26 PM
  #5  
SwissTony's Avatar
SwissTony
Thread Starter
Scooby Regular
20 Year Member
iTrader: (19)
 
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Default

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.
markus
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
Reply
Old Jul 22, 2006 | 12:04 PM
  #6  
jowl's Avatar
jowl
Scooby Regular
 
Joined: Aug 2004
Posts: 1,882
Likes: 0
Default

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
Reply
Old Jul 22, 2006 | 02:38 PM
  #7  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
Default

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.
Reply
Old Jul 23, 2006 | 01:54 AM
  #8  
stevencotton's Avatar
stevencotton
Scooby Regular
 
Joined: Jan 2001
Posts: 2,710
Likes: 1
From: behind twin turbos
Default

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):

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);
Oh, use this at your own risk. It will remove filename extensions

Last edited by stevencotton; Jul 23, 2006 at 02:11 AM.
Reply
Old Jul 23, 2006 | 02:03 AM
  #9  
corradoboy's Avatar
corradoboy
Scooby Regular
 
Joined: May 2003
Posts: 19,020
Likes: 0
From: Just beyond the limits of adhesion
Default

http://www.versiontracker.com/dyn/moreinfo/macosx/17205


Use this very regularly. Versatile, reliable, easy to use. Spot on
Reply
Old Jul 28, 2006 | 01:26 PM
  #10  
SwissTony's Avatar
SwissTony
Thread Starter
Scooby Regular
20 Year Member
iTrader: (19)
 
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Default

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.
mark
you have email..
Reply
Old Jul 28, 2006 | 01:27 PM
  #11  
SwissTony's Avatar
SwissTony
Thread Starter
Scooby Regular
20 Year Member
iTrader: (19)
 
Joined: Mar 2003
Posts: 28,233
Likes: 14
From: In the Doghouse
Default

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
works a treat
Reply
Old Jul 28, 2006 | 02:25 PM
  #12  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
Default

No problem at all Anything to help a fellow Mac user.
Reply
Related Topics
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
bugeyejohn
Wanted
4
Nov 6, 2015 02:31 PM
Nick_Cat
Computer & Technology Related
2
Sep 26, 2015 08:00 AM
Littleted
Computer & Technology Related
0
Sep 25, 2015 08:44 AM




All times are GMT +1. The time now is 04:27 PM.