frank1 has asked for the wisdom of the Perl Monks concerning the following question:
Am trying to delete files uploaded 1 hour below, on Dropbox but am getting this error. even tho i have files uploaded below 1 hour ago
No files found from the last hour to delete.
#!/usr/bin/perl use strict; use warnings; use DateTime; use JSON; use WebService::Dropbox; my $Token_id = ''; my $key = ''; my $secret = ''; # Initialize Dropbox client my $dropbox = WebService::Dropbox->new({ key => $key, secret => $secret, }); $dropbox->access_token($Token_id); # Calculate the timestamp from one hour ago my $one_hour_ago = DateTime->now()->subtract(hours => 1); my @files_to_delete; # List files from a specific folder # Use "" for root dir my $result = $dropbox->list_folder({ path => "" }); foreach my $file_metadata (@{ $result->{entries} }) { if ($file_metadata->{'.txt'} eq 'file') { # Parse the file's timestamp my $file_modified_dt = DateTime->from_iso8601($file_metadata-> +{client_modified}); # Check if the file was modified within the last hour if ($file_modified_dt > $one_hour_ago) { push @files_to_delete, $file_metadata->{path_display}; } } } if (@files_to_delete) { # Delete the collected files in a batch $dropbox->delete({ entries => \@files_to_delete }); print "Deleted " . scalar(@files_to_delete) . " files uploaded in +the last hour.\n"; } else { print "No files found from the last hour to delete.\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: DropBox Delete files
by 1nickt (Canon) on Dec 27, 2025 at 12:25 UTC | |
by frank1 (Monk) on Dec 27, 2025 at 20:49 UTC | |
|
Re: DropBox Delete files
by Corion (Patriarch) on Dec 26, 2025 at 19:35 UTC | |
by frank1 (Monk) on Dec 26, 2025 at 21:36 UTC |