Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9224355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:17:56+00:00 2026-06-18T04:17:56+00:00

I do have a third-party program, which uploads files to a webserver. These files

  • 0

I do have a third-party program, which uploads files to a webserver. These files are images, in different folders and with different names. Those files get references into a database. The program imports new images and upload those to those folders. If there is an existing file, it just takes the name and add a special counter, create a new reference in the database and the old one will be removed. But instead of removing the file as well, it keeps a copy.

Lets say, we have a image-file name “109101.jpg”.
There is a new version of the file and it will be uploaded with the filename: “109101_1.jpg”. This goes further till “109101_103.jpg” for example.
Now, all the 103 files before this one are outdated and could be deleted.

Due to the fact, that the program is not editable and third-party, I am not able to change that behavior. Instead, I need a Shell script, which walks through those folders and deletes all the images before the latest one. So only “109101_103.jpg” will survive and all the others before this number will be deleted.
And as a side effect, there are also images, with a double underscored name (only these, no tripple ones or so).
For example: “109013_35_1.jpg” is the original one, the next one is “109013_35_1_1.jpg” and now its at “109013_35_1_24.jpg”. So only “109013_35_1_24.jpg” has to survive.

Right now I am not even having an idea, how to solve this problem. Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T04:17:57+00:00Added an answer on June 18, 2026 at 4:17 am

    Here’s a one line pipeline, because I felt like it. Shown with newlines inserted because I’m not evil.

    for F in $(find . -iname '*.jpg' -exec basename {} .jpg \;
                 | sed -r -e 's/^([^_]+|[^_]+_[^_]+_[^_]+)_[0-9]+$/\1/'
                 | sort -u); do
        find -regex ".*${F}_[0-9]*.jpg" 
           | sort -t _ -k 2 -n | sort -n -t _ -k 4 -s | head -n -1;
    done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an old, third party, command line, proprietary program which I'm calling from
I have a third party SDK in C# which has class names like this:
I have a third party program which basically allows users to send email and
I have a third party java program called kgsgtp.jar which need to communicate with
I a have third party function which I use in my program. I can't
I have a third party DLL i need to call from my C# program.
I have a program that needs several third-party libraries, and at the moment it
I have a Windows Mobile program that accesses an attached device through a third-party
I have third party sites that link to some images on my site. The
I have a third-party library (the interface to Xerox's Finite State tools) which come

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.