1 #!/usr/bin/perl -w
2 # File: file_names.pl
3 # Author: Tom Large - tlarge@thelug.org
4 # Location: http://www.thelug.org/docs/
5 # Description: Lists the current directory, and displays
6 # all entries in a standard all lowercase with no spaces
7 # format. This script could easily be modified for
8 # purposes along the lines of standardzing a naming
9 # scheme for an mp3 collection, image collection or
10 # script collection.
11
12 $fn = "filenames.txt";
13
14 # Note: This assumes linux. If running in windows, comment the ls line,
15 # and uncomment the dir line.
16 system ("ls -1 > $fn");
17 #system ("dir /b > $fn");
18
19 open (THEFILE, "$fn");
20 @thefile = <THEFILE>;
21 close (THEFILE);
22 unlink($fn);
23
24 LINE: foreach $thefile (@thefile)
25 {
26 chomp $thefile;
27 $new_name = $thefile;
28 $new_name =~ s/\s/_/g;
29 $new_name =~ tr/A-Z/a-z/;
30 print "$new_name\n";
31 }
syntax highlighted by Code2HTML, v. 0.9.1