Welcome to the Power Users community on Codidact!
Power Users is a Q&A site for questions about the usage of computer software and hardware. We are still a small site and would like to grow, so please consider joining our community. We are looking forward to your questions and answers; they are the building blocks of a repository of knowledge we are building together.
Post History
Write a script to find the old files. Once you have a full treename of a file, it's trivial to delete it. Pretty much any command shell should be able to do this. Here is an example using my scr...
Answer
#2: Post edited
- Write a script to find the old files. Once you have a full treename of a file, it's trivial to delete it. Pretty much any command shell should be able to do this. Here is an example using my scripting language, <a href="http://www.embedinc.com/pic/escr">ESCR</a>:
- <pre>
- // SHOWOLD date
- //
- // Show all the files in the current tree that are older than DATE. The
- // format for DATE is YYYY/MM/DD.
- //
- var new thdate time = [arg 1]
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Subroutine OLDFILE tnam
- //
- // TNAM is the full treename of a file older than the threshold date/time.
- //
- subroutine oldfile
- var local tnam string = [vnl [arg 1]]
- show "Old file " tnam
- endsub
- ////////////////////////////////////////////////////////////////////////////////
- //
// Subroutine DODIR path- //
- subroutine dodir
- var local olddir string = [dir]
- loop dir "."
- pick one by [dent type]
- option "DIR"
- dir [dent]
- call dodir:+1 //process subdirectory recursively
- dir olddir
- option "FILE"
- if [< [dent dtm] thdate] then //older than the threshold ?
- call oldfile [dent tnam]
- endif
- endpick
- endloop
- endsub
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Start of main routine.
- //
- show "Files older than " thdate ":"
- call dodir
- </pre>
- Since I didn't actually want to delete files on my system, I have it only show the name of each old file. However, you could make subroutine OLDFILE do whatever you wanted, including deleting the file.
- If you want to run the above script directly, you'll have to install my ESCR scripter. It is included in the Full Runtime release at http://www.embedinc.com/pic/dload.htm.
- Again, similar things can be done with other scripting languages and most command shells.
- Write a script to find the old files. Once you have a full treename of a file, it's trivial to delete it. Pretty much any command shell should be able to do this. Here is an example using my scripting language, <a href="http://www.embedinc.com/pic/escr">ESCR</a>:
- <pre>
- // SHOWOLD date
- //
- // Show all the files in the current tree that are older than DATE. The
- // format for DATE is YYYY/MM/DD.
- //
- var new thdate time = [arg 1]
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Subroutine OLDFILE tnam
- //
- // TNAM is the full treename of a file older than the threshold date/time.
- //
- subroutine oldfile
- var local tnam string = [vnl [arg 1]]
- show "Old file " tnam
- endsub
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Subroutine DODIR
- //
- // Process all the files in the current directory and any of its
- // sub-directories.
- //
- subroutine dodir
- var local olddir string = [dir]
- loop dir "."
- pick one by [dent type]
- option "DIR"
- dir [dent]
- call dodir:+1 //process subdirectory recursively
- dir olddir
- option "FILE"
- if [< [dent dtm] thdate] then //older than the threshold ?
- call oldfile [dent tnam]
- endif
- endpick
- endloop
- endsub
- ////////////////////////////////////////////////////////////////////////////////
- //
- // Start of main routine.
- //
- show "Files older than " thdate ":"
- call dodir
- </pre>
- Since I didn't actually want to delete files on my system, I have it only show the name of each old file. However, you could make subroutine OLDFILE do whatever you wanted, including deleting the file.
- If you want to run the above script directly, you'll have to install my ESCR scripter. It is included in the Full Runtime release at http://www.embedinc.com/pic/dload.htm.
- Again, similar things can be done with other scripting languages and most command shells.
#1: Initial revision
Write a script to find the old files. Once you have a full treename of a file, it's trivial to delete it. Pretty much any command shell should be able to do this. Here is an example using my scripting language, <a href="http://www.embedinc.com/pic/escr">ESCR</a>: <pre> // SHOWOLD date // // Show all the files in the current tree that are older than DATE. The // format for DATE is YYYY/MM/DD. // var new thdate time = [arg 1] //////////////////////////////////////////////////////////////////////////////// // // Subroutine OLDFILE tnam // // TNAM is the full treename of a file older than the threshold date/time. // subroutine oldfile var local tnam string = [vnl [arg 1]] show "Old file " tnam endsub //////////////////////////////////////////////////////////////////////////////// // // Subroutine DODIR path // subroutine dodir var local olddir string = [dir] loop dir "." pick one by [dent type] option "DIR" dir [dent] call dodir:+1 //process subdirectory recursively dir olddir option "FILE" if [< [dent dtm] thdate] then //older than the threshold ? call oldfile [dent tnam] endif endpick endloop endsub //////////////////////////////////////////////////////////////////////////////// // // Start of main routine. // show "Files older than " thdate ":" call dodir </pre> Since I didn't actually want to delete files on my system, I have it only show the name of each old file. However, you could make subroutine OLDFILE do whatever you wanted, including deleting the file. If you want to run the above script directly, you'll have to install my ESCR scripter. It is included in the Full Runtime release at http://www.embedinc.com/pic/dload.htm. Again, similar things can be done with other scripting languages and most command shells.