递归删目录 for /r <TARGET DIR> %i in (<DIR NAME or Pattern>) do rd /s /q %i 递归删文件 for /r <TARGET DIR> %i in (<FILE NAME or Pattern>) do del /q %i dos命令中使用for在命令行可以执行但是在bat, cmd文件中不能执行? for /f %%a in ('dir /b') do echo %%a请看帮助for /?在批处理文
import os def local_rm(dirpath): if os.path.exists(dirpath): files = os.listdir(dirpath) for file in files: filepath = os.path.join(dirpath, file).replace("\\",'/') if os.path.isdir(filepath): local_rm(filepath) else: os.remove(filepath) os.rmdi
#!/usr/bin/perl use autodie; use utf8; use Encode qw(decode encode); sub del_dir{ my $path = shift @_; my @files = <$path/* $path/.*>; my @dirs = (); # save empty directory for( @files ){ next if /\.{1,2}$/g; # skip ./. ./.. directories (-d -e $_) ?