Infra_HDC icon

temporary rename all files in var subfolder

Infra_HDC | PRO | 10/25/24 01:42:49 PM UTC | 0 ⭐ | 8070 👁️ | Never ⏰ | []
Perl |

650 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/perl
# https://stackoverflow.com/questions/2601027/how-can-i-check-if-a-file-exists-in-perl
# https://stackoverflow.com/questions/3455956/how-do-i-get-the-dirname-of-a-file-with-perl
# https://stackoverflow.com/questions/67965882/finding-a-file-in-directory-using-perl-script
use File::Find;
use File::Basename;
 
my $curr_path="var";
 
my @content;
find( \&wanted, $curr_path);
 
for my $b (@content) {
    if (-f $b) {
    $tmp_name = dirname($b)."/1";
    rename $b, $tmp_name or die "$b: 1st rename error";
    rename $tmp_name, $b or die "$b: 2nd rename error";
    }
}
 
exit;
 
sub wanted {
    push @content, $File::Find::name;
  return;
}
 

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎