Here is my code which works:
<?php
$string = "e:
cd randomddirectory
unzip -o 84557".date("ymd")."*.zip -d Extracted";
file_put_contents("extract.bat", $string);
?>
But when I try to account for multiple files to be unzipped like below, it fails:
<?php
$string = "e:
cd randomddirectory
unzip -o 84557".date("ymd")."*.zip -d Extracted
unzip -o 84539".date("ymd")."*.zip -d Extracted
unzip -o 84527".date("ymd")."*.zip -d Extracted
unzip -o 84509".date("ymd")."*.zip -d Extracted";
file_put_contents("extract.bat", $string);
?>
How do I modify the syntax to get the multiple unzips working? It’s important the command is all within one string like above.
My guess is that
unzipis a batch file on its own here. So putcallbefore theunzipto make it work:I still think there are more sensible ways of doing this than creating a batch file and calling it from PHP. You’d run into probably every possible security barrier with this anyway.