Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] Delete a file without moving it to /dev/null

Expand Messages
  • Paul Archer
    unlink ... echo [q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq |dc (It s safe)
    Message 1 of 2 , Jan 24, 2005
      unlink

      5:21am, Alan wrote:

      >
      > Hi,
      >
      > The enclosed works on Linux for me.
      >
      > What term(s) (file io?) in the help for how to delete a file? (using
      > Perl), since,
      >
      > I also need a version that works on MS Windows (MS doesn't know what
      > /dev/null is). (nor the file permission).
      >
      > Put or die "Unable to read the dir: $!\n"; on the readdir() lines ?
      >
      > Any other tips/pointers?
      >
      > Hacked it this far along, so far. | Thanks. Alan.
      >
      > #!/usr/bin/perl
      > # orig pics are at: /home/al/tntst/*.*
      > # creates thumbs directory at: /home/al/tntst/thumbs
      > # copies all orig pics into the thumbs directory
      > # changes dir to the thumbs dir, then, uses
      > # ImageMagick to source .png and .jpg to outputs
      > # resized to .jpg Then, since want to keep only .jpg
      > # cleans up by deleting anything that is not .jpg
      > use strict;
      > use warnings;
      > use File::chdir;
      > use File::Copy;
      > my $dir;
      > my @pics;
      > @CWD = qw(home al tntst);
      >
      > # prints: /home/al/tntst
      > print "$CWD\n";
      > opendir DIR, "." or die "Can't open $dir: $!\n";
      > @pics = readdir(DIR);
      > closedir DIR;
      > mkdir "thumbs", 0777 unless -d "thumbs";
      > my $folder = '/home/al/tntst/thumbs/';
      > foreach my $item (@pics) {
      > my $old = "$item";
      > my $new = "$folder$item";
      > copy( $old, $new );
      > }
      > push @CWD, 'thumbs';
      >
      > # prints: /home/al/tntst/thumbs
      > print "$CWD\n";
      > system("mogrify -resize 544x408 -format jpg *.*");
      > opendir DIR, "." or die "Can't open $dir: $!\n";
      > my @fils = readdir(DIR);
      > closedir DIR;
      > foreach my $file (@fils) {
      > unless ( $file =~ /.*\.jpg/ ) {
      > my $dev_null = "/dev/null";
      > move( $file, $dev_null );
      > }
      > }
      >
      > # an as yet incompleted sub routine
      > #dothumbs();
      > # sub dothumbs {
      > # local $CWD;
      > # push @CWD, 'thumbs';
      > # print "$CWD\n";
      > # system("mogrify -resize 544x408 -format jpg *.*");
      > # }
      > # end ---------- the end --------------
      >
      >
      > Unsubscribing info is here: http://help.yahoo.com/help/us/groups/groups-32.html
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
      >

      ----------------------------------------------------------------------------
      echo '[q]sa[ln0=aln256%Pln256/snlbx]sb3135071790101768542287578439snlbxq'|dc
      (It's safe)
      ----------------------------------------------------------------------------
    Your message has been successfully submitted and would be delivered to recipients shortly.