Last active
November 3, 2015 15:01
-
-
Save dsueiro/cd9799b7ffa81338bc1b to your computer and use it in GitHub Desktop.
name_md5
This file contains 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
#!/usr/bin/php | |
<?php | |
if (count($argv) < 3 || count($argv) > 4) { | |
die("Uso:\n\tphp {$argv[0]} <filename> type [--no_underscores]\nIt generates a file yyyymmddhhiiss_md5hash_type.csv with or yyyymmddhhiissmd5hahstype.csv if --no-underscores is indicated\n"); | |
} | |
$oldname = $argv[1]; | |
$type = $argv[2]; | |
$glue = empty($argv[3]) || $argv[3] != "--no-underscores" ? "_" : ""; | |
$newname = date('YmdHis'). $glue . md5_file($oldname) . $glue . $type . '.csv'; | |
copy($oldname, $newname); | |
echo "The newname is $newname\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment