【发布时间】:2013-03-24 02:13:28
【问题描述】:
我正在尝试编写一个脚本,它将文件移动到基于文件名创建的文件夹中 每个文件有 2 个副本,名称完全相同,但文件扩展名不同。
例子
之前
dir1 - one.txt one.rtf two.txt two.rtf other.txt other.rtf
之后
dir1 - one two other
dir1/one - one.txt one.rtf
dir1/two - two.txt two.rtf
dir1/other - other.txt other.rtf
我之前将文件放在文件夹脚本中,但我不确定如何将多个文件放入 1 个文件夹中
这是文件到文件夹的代码。
#!/bin/bash
dir="/home/user1/Desktop/f2f/"
for file in ${dir}/*
do
mkdir -p "${file/./#}"
mv "${file}" "${file/./#}/"
done
无论如何,我们将不胜感激,如果有帮助,命名约定和文件扩展名将始终相同
【问题讨论】: