Long file name tool..OSX
#1
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
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
#2
Scooby Regular
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes
on
0 Posts
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.
#5
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
#7
Scooby Regular
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes
on
0 Posts
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
#8
Scooby Regular
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; 23 July 2006 at 02:11 AM.
#9
Scooby Regular
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
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