Skip to content

Instantly share code, notes, and snippets.

@kanasite
Created November 24, 2016 02:01
Show Gist options
  • Save kanasite/c04e500d76fcc13eaa9060503e6a446f to your computer and use it in GitHub Desktop.
Save kanasite/c04e500d76fcc13eaa9060503e6a446f to your computer and use it in GitHub Desktop.
Rename file to uuid.mp4
<?php
$handle = fopen("/Volumes/WD/matched_video.txt", "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
// OK: 3d46074a-6502-4600-9816-88a16bf51ac9--------$filename
$uuid = substr($line, 4, 36);
$filename = substr($line, 48);
$filename_without_extension = preg_replace('/\\.[^.\\s]{3,4}$/', '', $filename);
if(rename("/Volumes/WD/final/".$uuid."/".$filename, "/Volumes/WD/final/".$uuid."/".$filename_without_extension.".mp4")){
echo "OK: ".$uuid."\n\r";
}else{
echo "FAILED: ".$uuid."\n\r";
}
}
fclose($handle);
} else {
echo "Unable to read file";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment