【SH/BAT脚本】遍历文件夹

一、BAT

@echo off

set DIR=%~dp0

set ROOT=%DIR%excel

for /f "delims=" %%f   in ('dir  /b/a-d/s  %ROOT%\*.xls')  do (

echo %%f

)

pause

二、SH

# !/usr/bin/sh

DIR=$(cd "$(dirname "$0")"; pwd)

ROOT=$DIR/excel

for file in $ROOT/*.xls

do

echo $file

done

你可能感兴趣的:(【SH/BAT脚本】遍历文件夹)