Hello,
Is there a way to delete every files of an item with a single click and without deleting the item and its metadata ?
Thanks,
There’s not really a way to delete all the files with just a single click. You’d have to remove them one by one.
In case someone finds this thread while looking for the same thing, below is a script I have written for this job. It might be dangerous as it doesn’t do any check. I had to run it for only 3 items so didn’t bother much but that might break things, be careful!
<?php
# Change this value to the id of the item you want to clean
$item_id = 12345;
require_once "/export/www/bootstrap.php";
$autoloader = Zend_Loader_Autoloader::getInstance();
$application = new Omeka_Application(APPLICATION_ENV);
// APP_DIR."/config/application.ini");
$application->getBootstrap()->setOptions(array(
'resources' => array(
'theme' => array(
'basePath' => THEME_DIR,
'webBasePath' => WEB_THEME
)
)
));
$application->initialize();
$db = get_db();
$item = get_record_by_id('item', $item_id);
set_loop_records('files', $item->getFiles());
foreach (loop('files') as $file) {
print $file->original_filename."\t".$file->filename."\n";
$file->delete();
}
?>