Hi, I'm very new to perl and am trying to write a script that will basically say "look in a folder and if the file that is in that folder is the same as any of the files in a second folder then rename the first file by adding an "_1". There will always only be one file in the first folder but can be many in the second folder. I wrote the code below but it doesn't seem to do anything. Help would be appreciated. Thanks!
#! /usr/bin/perl use diagnostics; $tempdir="c:/Temp/OneFile"; opendir(TMP, $tempdir) || die; @onefile= readdir(TMP); closedir(TMP); $permdir="c:/Support/Files"; opendir(PMD, $permdir) || die; @allfiles= readdir(PMD); closedir(PMD); our @onefile_1; foreach $file (@allfiles) { if ($file eq "@onefile") { rename("$onefile", "@onefile_1.txt"); } } exit(0); __END__ :endofperl
In reply to comparing folders by grmshw4
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |