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 21 July 2006, 04:12 PM
  #1  
SwissTony
Scooby Regular
Thread Starter
iTrader: (19)
 
SwissTony's Avatar
 
Join Date: Mar 2003
Location: In the Doghouse
Posts: 28,226
Received 12 Likes on 3 Posts
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
Old 21 July 2006, 04:52 PM
  #2  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 21 July 2006, 04:57 PM
  #3  
SwissTony
Scooby Regular
Thread Starter
iTrader: (19)
 
SwissTony's Avatar
 
Join Date: Mar 2003
Location: In the Doghouse
Posts: 28,226
Received 12 Likes on 3 Posts
Default

markus

cheers big ears

will sort this out when i come back into the office.
stay tuned sir and thanks
Old 21 July 2006, 09:28 PM
  #4  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 21 July 2006, 10:26 PM
  #5  
SwissTony
Scooby Regular
Thread Starter
iTrader: (19)
 
SwissTony's Avatar
 
Join Date: Mar 2003
Location: In the Doghouse
Posts: 28,226
Received 12 Likes on 3 Posts
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
Old 22 July 2006, 12:04 PM
  #6  
jowl
Scooby Regular
 
jowl's Avatar
 
Join Date: Aug 2004
Posts: 1,882
Likes: 0
Received 0 Likes on 0 Posts
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
Old 22 July 2006, 02:38 PM
  #7  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
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.
Old 23 July 2006, 01:54 AM
  #8  
stevencotton
Scooby Regular
 
stevencotton's Avatar
 
Join Date: Jan 2001
Location: behind twin turbos
Posts: 2,710
Likes: 0
Received 1 Like on 1 Post
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; 23 July 2006 at 02:11 AM.
Old 23 July 2006, 02:03 AM
  #9  
corradoboy
Scooby Regular
 
corradoboy's Avatar
 
Join Date: May 2003
Location: Just beyond the limits of adhesion
Posts: 19,020
Likes: 0
Received 0 Likes on 0 Posts
Default

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


Use this very regularly. Versatile, reliable, easy to use. Spot on
Old 28 July 2006, 01:26 PM
  #10  
SwissTony
Scooby Regular
Thread Starter
iTrader: (19)
 
SwissTony's Avatar
 
Join Date: Mar 2003
Location: In the Doghouse
Posts: 28,226
Received 12 Likes on 3 Posts
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..
Old 28 July 2006, 01:27 PM
  #11  
SwissTony
Scooby Regular
Thread Starter
iTrader: (19)
 
SwissTony's Avatar
 
Join Date: Mar 2003
Location: In the Doghouse
Posts: 28,226
Received 12 Likes on 3 Posts
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
Old 28 July 2006, 02:25 PM
  #12  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

No problem at all Anything to help a fellow Mac user.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Mattybr5@MB Developments
Full Cars Breaking For Spares
28
28 December 2015 11:07 PM
Mattybr5@MB Developments
Full Cars Breaking For Spares
12
18 November 2015 07:03 AM
bugeyejohn
Wanted
4
06 November 2015 02:31 PM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: Long file name tool..OSX



All times are GMT +1. The time now is 06:35 PM.