diff --git a/file_lock.admin.inc b/file_lock.admin.inc
index 3dd4815..eeacb99 100644
--- a/file_lock.admin.inc
+++ b/file_lock.admin.inc
@@ -9,6 +9,20 @@
  * Administrative form for browsing files and performing operations on them.
  */
 function file_lock_admin_config($form, &$form_state) {
+  $form['lock'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Lock files'),
+  );
+  $form['lock']['lock_files'] = array(
+    '#type' => 'submit',
+    '#value' => t('Lock all existing files'),
+    '#submit' => array('file_lock_lock_existing_files_form_submit'),
+  );
+
+  if (variable_get('file_lock_mode', 'none') == 'none') {
+    $form['lock']['lock_files']['#value'] = t('Unlock all existing files');
+  }
+
   $form['file_lock_mode'] = array(
     '#type' => 'radios',
     '#title' => t('Automatic file lock'),
@@ -107,3 +121,61 @@ function file_lock_admin_config_validate($form, &$form_state) {
     form_set_error('file_lock_regex', t('RegEX pattern must not be empty.'));
   }
 }
+
+/**
+ * Lock existing files.
+ */
+function file_lock_lock_existing_files_form_submit() {
+  $batch = array(
+    'title' => t('Locking existing files'),
+    'operations' => array(
+      array('_file_lock_lock_existing_files', array()),
+    ),
+    'finished' => '_file_lock_lock_existing_files_finished_callback',
+    'file' => drupal_get_path('module', 'file_lock') . '/file_lock.admin.inc',
+  );
+  batch_set($batch);
+}
+
+function _file_lock_lock_existing_files(&$context) {
+  if (empty($context['sandbox'])) {
+    $context['sandbox']['progress'] = 0;
+    $context['sandbox']['current_file'] = 0;
+    $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT fid) FROM {file_managed}')->fetchField();
+  }
+  $limit = 5;
+  $result = db_select('file_managed')
+    ->fields('file_managed', array('fid'))
+    ->condition('fid', $context['sandbox']['current_file'], '>')
+    ->orderBy('fid')
+    ->range(0, $limit)
+    ->execute();
+  foreach ($result as $row) {
+    $file = file_load($row->fid);
+    if (variable_get('file_lock_mode', 'none') == 'none') {
+      file_lock_remove_lock($file);
+    }
+    else {
+      file_lock_act_on($file);
+    }
+    $context['sandbox']['progress']++;
+    $context['sandbox']['current_file'] = $file->fid;
+    $context['message'] = check_plain($file->filename);
+    $context['results'][] = $file->fid;
+  }
+  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
+    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+  }
+}
+
+function _file_lock_update_lock_existing_files_finished_callback($success, $results, $operations) {
+  // The 'success' parameter means no fatal PHP errors were detected. All
+  // other error management should be handled using 'results'.
+  if ($success) {
+    $message = format_plural(count($results), 'One file locked.', '@count files locked.');
+  }
+  else {
+    $message = t('Finished with an error.');
+  }
+  drupal_set_message($message);
+}
diff --git a/file_lock.install b/file_lock.install
index c56e488..1346dfb 100644
--- a/file_lock.install
+++ b/file_lock.install
@@ -5,7 +5,6 @@
  * Install, update, and uninstall functions for the file_lock module
  */
 
-
 /**
  * Implements hook_uninstall().
  */
@@ -14,6 +13,9 @@ function file_lock_uninstall() {
   variable_del('file_lock_pattern');
   variable_del('file_lock_regex');
   variable_del('file_lock_hook');
+  db_delete('file_usage')
+    ->condition('module', 'file_lock')
+    ->execute();
 }
 
 /**
