获取文件夹下所有文件名称
## 获取文件夹下所有文件名称
windows bat脚本
```
DIR *.* /s/b >list.txt
```
linux sh脚本
```
#!/bin/bash
function getdir(){
for element in `ls $1`
do
dir_or_file=$1"/"$element
if [ -d $dir_or_file ]
then
getdir $dir_or_file
else
echo $dir_or_file
fi
done
}
root_dir=$(cd `dirname $0`; pwd)
getdir $root_dir>list.txt
echo 'END!'
echo '请查看当前目录下 list.txt 文件'
```
[解决Linux环境下执行脚本时报错:/bin/bash^M: 坏的解释器: 没有那个文件或目录](https://blog.csdn.net/ouyang_peng/article/details/86488451)
**错误原因**
这个文件在Windows 下编辑过,在Windows下每一行结尾是\n\r,而Linux下则是\n,所以才会有 多出来的\r。
**修改错误**
使用指令sed -i 's/\r$//' xxxxxxx.sh
## 获取文件夹下所有录音文件名及时长
windows-[playTime.exe](https://pan.baidu.com/s/1TwxZ45ze2FnKTUKIH89ATg) 提取码:1204
