Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Applications / Mac Applications / October 2006



Tip: Looking for answers? Try searching our database.

trimming file names

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel Cohen - 09 Oct 2006 14:46 GMT
With Applescript (script provided by Apple) or File Buddy it's easy to
trim a fixed sequence of characters from a bunch of files.

What I am going to need to do is to remove date stamps from a whole
bunch of files. So a fixed number of characters but variable characters,
all numbers. A trim of a specified number of charaacters would be fine.

Are there any (preferably free) scripts or programs to do this?

Signature

http://www.decohen.com
Send e-mail to the Reply-To address;
mail to the From address is never read

Tom Stiller - 09 Oct 2006 15:51 GMT
> With Applescript (script provided by Apple) or File Buddy it's easy to
> trim a fixed sequence of characters from a bunch of files.
[quoted text clipped - 4 lines]
>
> Are there any (preferably free) scripts or programs to do this?

If you're comfortable with regular expressions, the script below will do
the job.

------------------- cut here ----------------------------------
#!/usr/bin/perl

# Usage: rename perlexpr [files]

($op = shift) || die "Usage: rename perlexpr [filenames]\n";
if(!@ARGV) {
  @ARGV = <STDIN>;
  chop (@ARGV);
}
for (@ARGV) {
  $was = $_;
  eval $op;
  die $@ if $@;
  rename($was, $_) unless $was eq $_;
}
------------------- cut here ----------------------------------

Signature

Tom Stiller

PGP fingerprint =  5108 DDB2 9761 EDE5 E7E3
                  7BDA 71ED 6496 99C0 C7CF

Gerry - 09 Oct 2006 17:07 GMT
> With Applescript (script provided by Apple) or File Buddy it's easy to
> trim a fixed sequence of characters from a bunch of files.
[quoted text clipped - 4 lines]
>
> Are there any (preferably free) scripts or programs to do this?

I have an Apple supplied AppleScript that is labeled "Trim n Characters
From Selected Items" You have the option to enter the number of
characters you want to remove, either from the beginning or end of the
file name.

I got all the scripts I use either from the AppleScript web page, or
from earlier OS CDs that had "Extras" which included various scripts.
ryrtr - 10 Oct 2006 01:20 GMT
> With Applescript (script provided by Apple) or File Buddy it's easy to
> trim a fixed sequence of characters from a bunch of files.
[quoted text clipped - 4 lines]
>
> Are there any (preferably free) scripts or programs to do this?

i think this will do that : http://petermaurer.de/nasi.php?section=filelist
Daniel Cohen - 10 Oct 2006 15:59 GMT
Many thanks.

> > With Applescript (script provided by Apple) or File Buddy it's easy to
> > trim a fixed sequence of characters from a bunch of files.
[quoted text clipped - 6 lines]
>
> i think this will do that : http://petermaurer.de/nasi.php?section=filelist

Signature

http://www.decohen.com
Send e-mail to the Reply-To address;
mail to the From address is never read

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.