Last active
January 10, 2019 02:49
-
-
Save chrispian/de2e979060db906195aefb1a40332aff to your computer and use it in GitHub Desktop.
Organize Yummy FTP Bookmarks
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
<?php | |
/** | |
* Quick script to organize YummyFTP bookmarks into alphabetical sub folders | |
* Run this in whatever directory you want to organize. | |
* | |
* You can set the folders to be upper or lower case and it also does 0-9 for domains that start with numbers | |
* @package CHB\Tools\YummyFTPOrg | |
* @author Chrispian Burks <chrispian@gmail.com> | |
* @param $upper_or_lower U for uppercase, null for lowercase. | |
*/ | |
$alpha_num = array_merge( range( 'a', 'z' ), range( '0', '9' ) ); | |
$upper_or_lower = 'U'; | |
foreach ( $alpha_num as $value ) { | |
if ( 'U' === $upper_or_lower ) { | |
$value = strtoupper( $value ); | |
} | |
if ( ! file_exists( $value ) ) { | |
mkdir( $value, 0777, true ); | |
} | |
foreach ( glob( '[' . strtolower( $value ) . strtoupper( $value ) . ']*.bkmk' ) as $filename ) { | |
rename( "$filename", "$value/$filename" ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment