Shell

#!/bin/bash

Project_dir=`pwd`
find $Project_dir -type d -a -name 'migrations' \
    -exec rm -rf {}/*_initial.py \;
echo "Done"

Python

#!/usr/bin/python
# -*- coding: utf-8 -*-

import os

BASE_DIR = os.path.dirname(os.path.abspath(__file__))
for app in os.listdir(BASE_DIR):
    if os.path.isdir(app):
        migrations = os.path.join(BASE_DIR, app, 'migrations')
        if os.path.exists(migrations):
            for logfile in os.listdir(migrations):
                if not logfile.startswith('__'):
                    os.remove(os.path.join(migrations, logfile))
                    print('Del', os.path.join(migrations, logfile))
print('Done')

相关文章:

  • 2022-12-23
  • 2021-11-21
  • 2021-11-21
  • 2021-11-21
  • 2022-01-07
  • 2021-12-03
猜你喜欢
  • 2021-09-15
  • 2021-06-03
  • 2021-09-04
  • 2021-12-21
  • 2022-12-23
  • 2021-12-13
相关资源
相似解决方案