Skip to content

Instantly share code, notes, and snippets.

@chrispian
Last active January 10, 2019 02:49
Show Gist options
  • Save chrispian/de2e979060db906195aefb1a40332aff to your computer and use it in GitHub Desktop.
Save chrispian/de2e979060db906195aefb1a40332aff to your computer and use it in GitHub Desktop.
Organize Yummy FTP Bookmarks
<?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