I have made changes step by step. and clear some errors, and the script outputs good, but when i check the files if deleted. there still there yet i got script on bottom saying

Files and folders in '': Deleted 6 files uploaded in the last hour.

my $access_token = ''; my $key = ''; my $secret = ''; # Initialize Dropbox client my $dropbox = WebService::Dropbox->new({ key => $key, secret => $secret, }); $dropbox->access_token($Token_id); # Specify the folder path you want to list. Use "" for the root folder +. my $folder_path = ""; # Call the list_folder method my $result = $dropbox->list_folder($folder_path); # Check for errors if ( $result->{'.sql'} eq 'error' ) { die "Error: " . Dumper($result); } my @files_to_delete; # Print the file and folder names print "Files and folders in '$folder_path':\n"; foreach my $entry ( $result->{entries}->@* ) { my $type = $entry->{'.txt'}; # 'file' or 'folder' my $name = $entry->{name}; my $path = $entry->{path_display}; my $server_modified = $entry->{server_modified}; # Define the format pattern (Z means UTC/GMT time zone) my $format_pattern = "%Y-%m-%dT%H:%M:%SZ"; # Parse the string into a Time::Piece object my $time_obj = Time::Piece->strptime($server_modified, $format_pat +tern); # Extract the hour (returns a two-digit string, e.g., "17") my $hour = $time_obj->hour; # Get the current time in UTC # We use gmtime() because the input timestamp is in UTC ('Z' suffi +x) my $t2 = gmtime; # Calculate the difference in seconds my $diff_seconds = $t2 - $time_obj; # Convert the difference to total hours (as a floating-point numbe +r) my $diff_hours = $diff_seconds / ONE_HOUR; # printf("File $name uploaded %d hours, %d minutes, %d seconds ag +o\n", $diff_seconds / ONE_HOUR, ($diff_seconds % ONE_HOUR) / ONE_MINU +TE, $diff_seconds % ONE_MINUTE); # prints File file1.txt uploaded 3 hours, 16 minutes, 48 seconds a +go # Check if the file was modified within the last hour if ($diff_hours > 1) { push @files_to_delete, $entry->{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"; } # Printed Files and folders in '': Deleted 6 files uploaded in the las +t hour.

In reply to Re^2: DropBox Delete files by frank1
in thread DropBox Delete files by frank1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.