English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have OS 10. I have thousands of pictures I need to organize. I want to have a 3 digit number before each file that will be the same for multiple files. (ex. 123-01,123-02, 123-03.......) I don't want to enter it all by hand. Is there a script or program to help me?

2007-08-04 10:01:49 · 2 answers · asked by MilVil J 2 in Computers & Internet Programming & Design

2 answers

OS 10 has Perl. This script will do that:

#!/usr/bin/perl

$DIR = "[YOUR DIRECTORY HERE]";
$PREFIX = "[YOUR PREFIX HERE]";

&doDir($DIR);

sub doDir {
local $myDir = shift;
chdir $myDir;
print "Checking directory \"", $myDir, "\"\n";
opendir DIR, $myDir || die("Could not open directory \"$myDir\"");
local @files = readdir DIR;
closedir DIR;

foreach $file (@files) {
next if $file eq ".";
next if $file eq "..";
local $ffn = $myDir . "/" . $file;
next if (-d $ffn); # Ignore directories
$newFile = $PREFIX . $file;
print $file, " -> ", $newFile, "\n";
rename $file, $newFile;
}
}

2007-08-04 10:48:01 · answer #1 · answered by McFate 7 · 0 0

In windows you can CTRL+A or hold CTRL and click on all the files you want and then choose rename and enter the 123 etc and they will all get batched together sequentially

2007-08-04 17:06:17 · answer #2 · answered by Anonymous · 0 1

fedest.com, questions and answers