I make no guarantees but this seems to work.  Call it whatever
you want and pass it a list of files to use.  It can also take
filenames from stdin.

e.g. To rename all files in the current directory
mv-command *  


--Juan

############# CUT HERE #########################
!/usr/bin/perl

if (!@ARGV) {
        @files = <STDIN>;
        chomp (@files);
}
else {
        @files = @ARGV;
        @ARGV = ();
}

#
# Save the filename.
# Prompt for user and title
# Rename file.
#
for (@files) {
        $was = $_;
        print "$was\n";
        print "Name: ";
        chomp ($name = <>);
        print "Doc Title: ";
        chomp ($title = <>);
        print "\n";
        $_ = "[\u$name]-\u$title.txt";
        rename($was,$_) unless $was eq $_;
}
############# CUT HERE #########################

Write a wise saying and your name will live forever.
                -- Anonymous

On Sun, 30 Jan 2000, Gate wrote:

> Date: Sun, 30 Jan 2000 03:50:01 -0800 (PST)
> From: Gate <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> To: [EMAIL PROTECTED]
> Subject: renaming files with script
> Resent-Date: 30 Jan 2000 11:46:23 -0000
> Resent-From: [EMAIL PROTECTED]
> Resent-cc: recipient list not shown: ;
> 
> Hi
> 
> Does anyone have a script to rename files into a specified format? What I
> would like to have it do is when executed in a directory, list each file,
> prompt for a Name:, then you type that, it prompts for a Doc Title:, type
> that, and then it renames the file into a format like [Name]-Doc
> Title.txt.
> So:
> [me@here /me]$ mv-command
> my first file.txt
> Name: <i type JOHN>
> Doc Title: <i type first doc>
> 
> my sec file.txt
> Name: <i type james>
> Doc Title: <i type second doc>
> 
> [me@here /me]$ ls
> [John]-First Doc.txt
> [James]-Second Doc.txt
> 
> It would be even better if it would automaticall capitalize the first
> letter of each word.. Anyone have any ideas? I've been trying to do it in
> perl but can't figure it out..
> 
> Thanks in advance!
> 
>       Bryan
> 
> 
> -- 
> To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
> as the Subject.
> 


-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to