Path: news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!usc!elroy.jpl.nasa.gov!netline-fddi.jpl.nasa.gov!nntp-server.caltech.edu!nathan From: nathan@cco.caltech.edu (Nathan Mates) Newsgroups: comp.sys.apple2 Subject: Re: Filename Fix Help Date: 19 Mar 1995 04:42:43 GMT Organization: California Institute of Technology, Pasadena Lines: 72 Message-ID: <3kgco3$e17@gap.cco.caltech.edu> References: <3kd701$4tv@lucy.infi.net> NNTP-Posting-Host: accord.cco.caltech.edu In article <3kd701$4tv@lucy.infi.net>, Dennis McClain-Furmanski wrote: >I've installed NAMEFIX in my system software, and so can accept nearly any >file name that gets thrwon at me. But I still have problems with >underscores. To download files I collect which have underscores in them, I >have to go through and do a >mv xxxxx_yyyy.zzz xxxxxyyyy.zzz >for every file. Ok, pretty trivial, assuming you have the language 'perl' installed on your unix box. Here's a program I just wrote up to do just that. Obviously, with a little work, it could be made to make all files fit ProDOS 8 filename conventions... --- Begin program. Cut here. Put in file 'nounder.prl' #!/usr/local/bin/perl -w # Converts all filenames with _'s in them to remove the _. Usage: # nounder.prl *_* # Make sure the user specified some files on the cmd line or give errors @ARGV >= 1 || die "Usgae: nounder.prl *_*\n"; for ($i=0;$i<@ARGV;$i++) { $_ = $ARGV[$i]; # put into working varb s/_//g; # remove all _'s if (-e $ARGV[$i]) { # make sure the specified file already exists rename($ARGV[$i],$_) || die "Can't rename file $_"; } } --- End program. Cut here. Ouch! The first line must contain the path to perl on your system, which can be determined as follows: # which perl /usr/local/bin/perl (Example from this system here. Two other systems I use a lot have it in very different places). This should work with almost all versions of Perl, but was only tested with version 4.0, pl36. Also, you'll have to make the program runnable, the unix chmod command does that: # chmod 755 nounder.prl Basically, it first checks to make sure you specified some names, or exits with an error message. Then, it goes through all the names you specified (which is why calling it with 'nounder.prl *_*' is the preferred way), rips any and all _'s out of the name, and renames the file. For example: # ls blah_2 # ~/progs/nounder.prl *_* # ls blah2 Have fun! Nathan Mates -- <*> Nathan Mates http://www.ugcs.caltech.edu/~nathan/ <*> # "When you hear the voice of heaven, go out and start running. No # matter how far away, set on a journey to be sure. ... No matter # how far away, I'll be there to meet you." -- Silent Moebius #1