diff options
| author | Jules Laplace <carbon@melanarchy.org> | 2015-09-01 00:51:03 -0500 |
|---|---|---|
| committer | Jules Laplace <carbon@melanarchy.org> | 2015-09-01 00:51:03 -0500 |
| commit | 73a22265ab53271122bf1f47bcca6e9604c5d159 (patch) | |
| tree | c110d9f9f4079405352da49de519f35fe78faa67 /bucky2/bin/rename-file | |
| parent | ca77a587da9ec393bceda87c2ec8dda096e2890d (diff) | |
html5 mp3 player
Diffstat (limited to 'bucky2/bin/rename-file')
| -rwxr-xr-x | bucky2/bin/rename-file | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/bucky2/bin/rename-file b/bucky2/bin/rename-file new file mode 100755 index 0000000..a060b1a --- /dev/null +++ b/bucky2/bin/rename-file @@ -0,0 +1,44 @@ +#!/usr/bin/perl +use strict; +use lib "../lib"; +use Bucky; + +if (scalar(@ARGV) < 2) { + print "usage: move-file file-id filename\n"; + exit(1); +} + +our $bucky = new Bucky; +our $file_id = $ARGV[0]; +our $filename = $ARGV[1]; + +rename_file($file_id, $filename); + +sub rename_file { + my ($file_id, $filename) = @_; + + my $files = $bucky->db->select('file', { id => $file_id }); + my $file = $files->[0]; + + my $path = $ENV{"HOME"} . "/bucky/data/"; + + print $path . $file->{'thread'} . "/" . $filename . "\n"; + if (-e $path . $file->{'thread'} . "/" . $filename) { + print "file exists!\n"; + return + } + print "renaming " . $file->{'filename'} . " => " . $filename . "\n"; + + system("/bin/mv", + $path . $file->{'thread'} . "/" . $file->{'filename'}, + $path . $file->{'thread'} . "/" . $filename); + + $bucky->db->update_by_id('file', { + "id" => $file_id, + "record" => { + "filename" => $filename + } + }); +} + + |
