[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
- <!--x-content-type: text/plain -->
- <!--x-date: Wed Apr 7 22:06:26 2004 -->
- <!--x-from-r13: rfbgrevp ng 3gvzrf25.arg (Urbsserl) -->
- <!--x-message-id: [email protected] -->
- <!--x-reference: [email protected] --> "http://www.w3.org/TR/html4/loose.dtd">
- <!--x-subject: [ale] "motion" and snapshots? -->
- <li><em>date</em>: Wed Apr 7 22:06:26 2004</li>
- <li><em>from</em>: esoteric at 3times25.net (Geoffrey)</li>
- <li><em>in-reply-to</em>: <<a href="msg00257.html">[email protected]</a>></li>
- <li><em>references</em>: <<a href="msg00257.html">[email protected]</a>></li>
- <li><em>subject</em>: [ale] "motion" and snapshots?</li>
I've got a perl script around here that does a conversion like this, let
me look around...... Ah, here it is! It's ugly, it's old, it uses
static directory values, feel free to hack away at it. Hope it helps!
--
Until later, Geoffrey Registered Linux User #108567
Building secure systems in spite of Microsoft
-------------- next part --------------
#!/usr/bin/perl
# use diagnostics;
use strict;
my ($nfn, $fn, @parts, %newdir, %newfn, $i, $key, $value, %file, @df, @data);
chdir "/home/esoteric/watch" || die "died attempting to chdir";
my @files = `find . -name '*.jpg' -print`;
printf "files to move: %s\n", $#files + 1;
my @pre_df=`df /home/esoteric/store`;
foreach $fn (@files) {
# parse through each file name, and build the new filename
# and directory name the file will reside
chomp $fn;
@parts = split ("/", $fn);
$file{$fn} = $parts[0];
$newdir{$fn} = "/home/esoteric/store/archive/" .
substr($parts[1], 2, 2) . $parts[2] . $parts[3];
$newfn{$fn} = $parts[4] . $parts[5] . substr($parts[6], 0, 2);
for ($i = 1; $i < $#parts; $i++) {
$file{$fn} = $file{$fn} . "/" . $parts[$i];
}
}
my $count=0;
while (($key, $value) = each %file) { $count++; }
printf "files to move: %s\n", $count;
$count=0;
while (($key, $value) = each %file) {
# create the directory if it does not exist
if ( ! -d $newdir{$key} ) { mkdir $newdir{$key}; }
# insure unique file names
$nfn=$newdir{$key} . "/" . $newfn{$key} . ".jpg";
while ( -e $nfn ) {
printf "Found a duplicate <%s> and <%s>\n", $nfn, $newfn{$key};
print "Changing file name";
$nfn=$newdir{$key} . "/" . $newfn{$key} . "a.jpg";
}
# printf "moving %s to %s\n", $key, $nfn;
`/bin/mv $key $nfn`;
if ( ! -e $nfn ) { die "file doesn't exist, mv failed\n" }
# if ( $? != 0 ) {die "mv $key $nfn failed ($?)";}
$count++;
}
print "files moved: $count\n";
# $list=`find * -type d -depth -print`;
# print "list of directories located: $list\n";
`find * -type d -depth -print |xargs rmdir`;
@df=`df /home/esoteric/store`;
@data = split " ", $df[1];
$data[4] =~ s/%//;
print $pre_df[1];
print $df[1];
if ( $data[4] > 98 ) {
`/home/esoteric/shl/dosound /home/esoteric/sounds/intercom.au`;
}
exit;
</pre>
<!--X-Body-of-Message-End-->
<!--X-MsgBody-End-->
<!--X-Follow-Ups-->
<hr>
<ul><li><strong>Follow-Ups</strong>:
<ul>
<li><strong><a name="00264" href="msg00264.html">[ale] "motion" and snapshots?</a></strong>
<ul><li><em>From:</em> Robert.L.Harris at rdlg.net (Robert L. Harris)</li></ul></li>
</ul></li></ul>
<!--X-Follow-Ups-End-->
<!--X-References-->
<ul><li><strong>References</strong>:
<ul>
<li><strong><a name="00257" href="msg00257.html">[ale] "motion" and snapshots?</a></strong>
<ul><li><em>From:</em> Robert.L.Harris at rdlg.net (Robert L. Harris)</li></ul></li>
</ul></li></ul>
<!--X-References-End-->
<!--X-BotPNI-->
<ul>
<li>Prev by Date:
<strong><a href="msg00262.html">[ale] [Fwd: Average Salary for Programmers]</a></strong>
</li>
<li>Next by Date:
<strong><a href="msg00264.html">[ale] "motion" and snapshots?</a></strong>
</li>
<li>Previous by thread:
<strong><a href="msg00257.html">[ale] "motion" and snapshots?</a></strong>
</li>
<li>Next by thread:
<strong><a href="msg00264.html">[ale] "motion" and snapshots?</a></strong>
</li>
<li>Index(es):
<ul>
<li><a href="maillist.html#00263"><strong>Date</strong></a></li>
<li><a href="threads.html#00263"><strong>Thread</strong></a></li>
</ul>
</li>
</ul>
<!--X-BotPNI-End-->
<!--X-User-Footer-->
<!--X-User-Footer-End-->
</body>
</html>