Created: 2011-07-09 03:54
Updated: 2014-04-01 23:04


win32 scripts



C:\>python --help
usage: [-h] [-u USERNAME] DIR

recursively enable all permissions for files in target_dir

positional arguments:
  DIR                   target directory

optional arguments:
  -h, --help            show this help message and exit
  -u USERNAME, --user_account_name USERNAME
                        account name. Default is "Everyone".



C:\projects\win32-scripts>python --help
usage: [-h] [--temp-root TEMP_ROOT] [--actually-delete]
                           [--max-age MAX_AGE] [--log-level LOG_LEVEL]

deletes old files from your temp directory

optional arguments:
  -h, --help            show this help message and exit
  --temp-root TEMP_ROOT
                        root of temp dir. defaults to win32api.GetTempPath().
  --actually-delete     ACTUALLY DELETE. ARE YOU SURE?
  --max-age MAX_AGE     max age, in seconds. defaults to 2 weeks.
  --log-level LOG_LEVEL
                        log level

known issues:

  • this relies upon os.walk, which constructs a list of dirs and a list of files in the dir it is visiting. this means it is incredibly slow at navigating directories containing huge numbers of files/dirs. your top-level temp dir may be such a dir.

alternate approaches:

  1. -- which opens a dialog
  2. -- which uses registry settings, and breaks under windows 7 sometimes in ways the author of the article does not understand
Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more