Last active
December 29, 2015 18:39
-
-
Save aweijnitz/7712587 to your computer and use it in GitHub Desktop.
PHP script to copy ukulele advent calendar submissions using the day of month as base file name
(i.e. 1.htm, 1.mp3, 1.jpg on Dec 1st and so on)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>My First PHP Page</title> | |
</head> | |
<body> | |
<?php | |
// Change these to actual directory paths (including trailing slash '/') | |
$SOURCE_DIR = '/Users/anders/tmp/from/'; | |
$DESTINATION_DIR = '/Users/anders/tmp/to/'; | |
date_default_timezone_set('CET'); | |
$filePrefix = date("j"); // Returns the day of month (ex. '1' for Dec 01) | |
$htmlFile = $filePrefix . '.htm'; | |
$imgFile = $filePrefix . '.jpg'; | |
$mp3File = $filePrefix . '.mp3'; | |
$files = array($htmlFile, $imgFile, $mp3File); | |
foreach ($files as $file) { | |
$FROM = $SOURCE_DIR . $file; // path to source file. Ex 'from/1.htm' | |
$TO = $DESTINATION_DIR . $file; // path to destination file. Ex. 'to/1.htm' | |
if(!copy($FROM, $TO)) { // do copy | |
echo "Failed to copy file $FROM to $TO<br />"; | |
} else | |
echo "Copied file $FROM<br />"; | |
} | |
phpinfo(); | |
?> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment