fancy_file_delete.drush.inc in Fancy File Delete 7
File
fancy_file_delete.drush.inc
View source
<?php
function fancy_file_delete_drush_command() {
$items = array(
'fancy-file-delete' => array(
'callback' => 'fancy_file_delete_drush_batch_delete_process',
'description' => 'Deletes any number of files by fid or path.',
'aliases' => array(
'ffd',
),
'arguments' => array(
'files' => "A comma separate list of file ID's OR \n relative paths to any files you wish to delete.",
),
'options' => array(
'force' => 'Forcefully remove the file, even if it is still being referenced.',
),
),
);
return $items;
}
function fancy_file_delete_drush_help($section) {
switch ($section) {
case 'drush:fancy-file-delete':
return "Deletes any number of files by fid or path.";
}
}
function fancy_file_delete_drush_batch_delete_process($file_list) {
$operations = array();
$confirm = drush_confirm('WARNING! Are you sure you want to delete these files?');
if (!$confirm) {
drush_user_abort();
return;
}
$files = explode(',', $file_list);
$force = drush_get_option('force', FALSE);
foreach ($files as $file) {
$operations[] = array(
'fancy_file_delete_batch_delete',
array(
$file,
$force,
),
);
}
$batch = array(
'operations' => $operations,
'title' => 'Deleting files.',
'init_message' => 'Initializing.',
'error_message' => 'An error occurred during file deletion.',
'finished' => 'fancy_file_delete_batch_delete_finished',
'file' => drupal_get_path('module', 'fancy_file_delete') . '/includes/fancy_file_delete.batch_delete.inc',
);
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
drush_backend_batch_process();
}