Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

how to delete old files

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to delete old files

    I want to delete backup files older than 90 days according to the date used when you open windows explorer.
    I know the folder and first 6 letters of the files: s:\backup20121116.zip

    can we still use .bat files? del S:\Backup????????.zip 'older the date()-90

    Thanks,

    Tom

  • #2
    Re: how to delete old files

    I see a reply by Stan below. My search didn't find it.

    Anyway, I'm studying FileFind, not sure how to get the date filter - yet.

    file_list = filefind.get("c:\temp_FILEs\*.tmp", 0, "PN")

    *for_each(filename, file.remove(filename), file_list)

    Additional help would be appreciated.

    Tom

    Comment


    • #3
      Re: how to delete old files

      Code:
      lst = filefind.get("s:\*.zip",FILE_FIND_NORMAL,"PN")
      
      for each foo in lst
      	if extract_string(foo.value,"p",".") < cdate(date()-90)
      	file.remove(foo.value)
      	end if
      next
      There can be only one.

      Comment


      • #4
        Re: how to delete old files

        Stan,

        Thanks again for the quick reply.

        I'm not understanding the code. What do I substitute for the "foo"? Sorry to be so dense!

        Tom

        Comment


        • #5
          Re: how to delete old files

          Nothing.

          Foo is just a placeholder variable. As used it contains each path_filename in turn.

          Should be able to run the code as shown.
          There can be only one.

          Comment


          • #6
            Re: how to delete old files

            Hi Again,

            I setup a test as below and it doesn't work. I added the T to PNT so it got the date field. When I look at the Date Modified column in Windows Explorer it includes the time also. Would that make a difference?

            lst = filefind.get("c:\AA_Test\*.zip",FILE_FIND_NORMAL,"PNT")

            for each foo in lst
            if extract_string(foo.value,"p",".") < cdate(date()-13)
            file.remove(foo.value)
            end if
            next

            ui_msg_box("Done","Process Complete")

            END

            Comment


            • #7
              Re: how to delete old files

              Spoke too soon. I deleted one file on my first test when I used the exact name of the file instead of wildcards. But now it won't work.

              Think I better take a break.

              Tom

              Comment


              • #8
                Re: how to delete old files

                Yes. "PNT" won't work.

                File.remove(drive_path_times) does't compute.

                The filename to be removed doesn't have the time at the end.
                There can be only one.

                Comment


                • #9
                  Re: how to delete old files

                  The following code works if I squote out '<cdate(date()-90)

                  How can I change it to delete with the "<cdate(date()-90)"??

                  lst = Filefind.get("c:\AA_Test\*.zip",FILE_FIND_NORMAL,"PN")

                  for each foo in lst
                  if extract_string(foo.value,"p",".") '< cdate(date()-90)
                  file.remove(foo.value)
                  end if
                  next

                  ui_msg_box("Done","Process Complete")

                  END
                  Thanks for taking another look.

                  Tom

                  Comment


                  • #10
                    Re: how to delete old files

                    I added the date to the end of the backup file, backup20121116. Then I did the math.

                    lst = filefind.get("c:\AA_Test\*.ZIP",FILE_FIND_NORMAL,"PN")

                    for each foo in lst
                    ui_msg_box("Foo",right(Word(Foo,2),8))
                    'goto Skp_this
                    IF val(cdate(date()))- val(right(Word(Foo,2),8))>300 then

                    file.remove(foo.value)

                    end if
                    'skip_this:
                    next

                    ui_msg_box("Done","Process Complete")

                    END
                    Thanks for getting me on the right track.

                    Tom

                    Comment


                    • #11
                      Re: how to delete old files

                      Not understood. You said the files were named in the pattern s:\backup20121116.zip.

                      What does
                      I added the date to the end of the backup file, backup20121116.
                      mean.
                      There can be only one.

                      Comment


                      • #12
                        Re: how to delete old files

                        Sorry Stan. Guess I got too tired working on this. I used the date on the end of the filename, rather than trying to get the date from filefind or extract_string.

                        Tom

                        Comment


                        • #13
                          Re: how to delete old files

                          Tom, I'm not quite sure if you got it working or not but I wanted to add this tidbit that may help others.

                          Instead of using something meaningless - and therefore confusing - like "foo" or "x", it might make more sense to people if they used something like "line_in_string" at least until they were more comfortable with the command. Once I realized this and did a couple this way, it started making a LOT more sense. I also started separating out the "do_something_to_the_line" part to make that easier to see also.

                          do_something_to_the_line = file.remove(line_in_string)
                          *for_each( line_in_string, do_something_to_the_line, input_string )


                          Of course, the do_something_to_the_line can also be a much more complicated expression using IF commands, CASE commands, lookups, etc., etc.

                          Once I understood it better I quit using some of those crutches but I still often use "line" as the first argument just to remind me that I'm actually working with a line in a crlf string. And, for my really complicated "do_something_to_the_line" expressions, I still sometimes separate those out. (And, of course, I use a variable name shorter than do_something_to_the_line!)

                          Hint: It's difficult to "remove" a line using *for_each(). If you want to remove some lines (something I find myself doing fairly often), just blank them out then you can use either Remove_blank_lines() or Sortsubstr() after the *for_each() function. The Sortsubstr() will remove the blank lines at the same time it sorts the list....
                          input_string = sortsubstr( input_string, crlf())

                          Comment


                          • #14
                            Re: how to delete old files

                            Thanks Cal. I got it working by using my file naming convention. I planned to use windows explorer "date created", but that proved too complicated. Anyway, the good news is, I got it working. Thanks for the tidbits. ~ Tom

                            Comment

                            Working...
                            X