#!/usr/bin/perl use strict; use lib "../lib"; use Bucky; if (scalar(@ARGV) < 2) { print "usage: move-file thread-id file-ids\n"; exit(1); } our $bucky = new Bucky; our $thread_id = $ARGV[0]; for (my $i = 1; $i < scalar(@ARGV); $i++) { move_file($ARGV[$i]); } sub move_file { my $file_id = shift; my $files = $bucky->db->select('file', { id => $file_id }); my $file = $files->[0]; my $path = $ENV{"HOME"} . "/bucky/data/"; print "moving " . $file->{'filename'} . "\n"; system("/bin/mkdir", "-p", $path . $thread_id); system("/bin/mkdir", "-p", $path . $thread_id . "/.thumb"); system("/bin/mv", $path . $file->{'thread'} . "/" . $file->{'filename'}, $path . $thread_id); $bucky->db->update_by_id('file', { "id" => $file_id, "record" => { "thread" => $thread_id } }); }