Created
November 24, 2016 02:01
-
-
Save kanasite/c04e500d76fcc13eaa9060503e6a446f to your computer and use it in GitHub Desktop.
Rename file to uuid.mp4
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
<?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