Skip to content

Instantly share code, notes, and snippets.

@jaceju
Created March 9, 2018 02:57
Show Gist options
  • Save jaceju/1a5d17aa9d150bf5bc465ac33170da0c to your computer and use it in GitHub Desktop.
Save jaceju/1a5d17aa9d150bf5bc465ac33170da0c to your computer and use it in GitHub Desktop.
Rename files
<?php
use Illuminate\Support\Str;
require __DIR__ . '/vendor/autoload.php';
$fs = new \Illuminate\Filesystem\Filesystem();
$filePaths = $fs->glob(__DIR__ . '/src/Schema/*/Create*.php');
foreach ($filePaths as $filePath) {
$file = new SplFileInfo($filePath);
$name = $file->getBasename();
$newPath = $file->getPath() . '/2018_03_01_000000_' . Str::snake($name);
$fs->move($file->getPathname(), $newPath);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment