Skip to content

Instantly share code, notes, and snippets.

@dsueiro
Last active November 3, 2015 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dsueiro/cd9799b7ffa81338bc1b to your computer and use it in GitHub Desktop.
Save dsueiro/cd9799b7ffa81338bc1b to your computer and use it in GitHub Desktop.
name_md5
#!/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