in reply to Re^5: 7zip a folder
in thread 7zip a folder

Basically, what I am doing now is to move all the files falling into my date range to a new folder which foldername is the timestamp of those files, then zip all the file under this folder, I could not get it through, because it is saying \$foldername\ the system cannot find the path specified.
$date = strftime("%Y-%m-%d", localtime); mkdir my $foldername = "D:/log_script/Archive/$date"; my @cmd = 'D:/app/7-Zip/7z.exe', 'a', '-mx9', 'D:/log_script/Archive/target.zip', '$foldername/*.log' ); print 'about to execute: ', Dumper \@cmd; system @cmd;

Replies are listed 'Best First'.
Re^7: 7zip a folder
by Corion (Patriarch) on Nov 06, 2017 at 19:24 UTC

    Have you printed @cmd before running it through system?

    If you have done so, you will see that single quotes do not interpolate variables. $forldername appears verbatim in your command.

    Most likely, you want to use double quotes instead:

    "$foldername/*.log",