Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Deleting a file if file size exceeds a threshold size

    I want to delete a dta file if its size is less than x kilobytes. I use the code below. The dta file in question is not less than x kilobytes but Stata still deletes it. Where am I going wrong?

    Code:
    checksum "data101201.dta"
    rm "data101201.dta" if r(filelen) < x
    return list


  • #2
    Code:
    checksum "data101201.dta"
    if r(filelen) < x{
        rm "data101201.dta"
    }
    should do what you want.

    Comment


    • #3
      It does. I should not have assumed that rm accepts the if condition. Thanks!

      Comment

      Working...
      X