回答編集履歴
4
誤り訂正
answer
CHANGED
@@ -20,4 +20,14 @@
|
|
20
20
|
|
21
21
|
```Bash
|
22
22
|
find [Directory] -type f | while read f;do mv -i </dev/tty $f ${f:0:4}-${f:5:2}-${f:8:2};done
|
23
|
+
```
|
24
|
+
#訂正
|
25
|
+
追記のスクリプトは間違っています。コメント参照。コメントに書いたことで解決したようですが、こちらも訂正しておきます。
|
26
|
+
```Bash
|
27
|
+
find [Directory] -type f | while read file
|
28
|
+
do
|
29
|
+
dir=${file%/*}
|
30
|
+
name=${file##*/}
|
31
|
+
mv -i </dev/tty "$file" "$dir/${name:0:4}-${name:5:2}-${name:8:2}"
|
32
|
+
done
|
23
33
|
```
|
3
誤り訂正
answer
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
`mv 元のファイル名 新しいファイル名`です。
|
2
2
|
|
3
3
|
```Bash
|
4
|
-
find [Directory] -type f | while read file; do mv -i $file ${file//A/B};done
|
4
|
+
find [Directory] -type f | while read file; do mv -i </dev/tty $file ${file//A/B};done
|
5
5
|
```
|
6
6
|
ディレクトリ以下の全てのファイルについて、リネームしてしまいますが、大丈夫でしょうか?
|
7
7
|
まずは、
|
@@ -19,5 +19,5 @@
|
|
19
19
|
> そして、"yyyy年mm月dd日あああ"のような無駄な文字列をまとめて削除すべく、先頭から10文字以外を削除するコマンドがあればそれも付け加えたいです。
|
20
20
|
|
21
21
|
```Bash
|
22
|
-
find [Directory] -type f | while read f;do mv -i $f ${f:0:4}-${f:5:2}-${f:8:2};done
|
22
|
+
find [Directory] -type f | while read f;do mv -i </dev/tty $f ${f:0:4}-${f:5:2}-${f:8:2};done
|
23
23
|
```
|
2
更新
answer
CHANGED
@@ -15,6 +15,7 @@
|
|
15
15
|
find [Directory] -type f | xargs -n 1 -p rename A B
|
16
16
|
```
|
17
17
|
#追記
|
18
|
+
> "yyyy年mm月dd日"という書式でネーミングされているものを"yyyy-mm-dd"に変えたいのです。
|
18
19
|
> そして、"yyyy年mm月dd日あああ"のような無駄な文字列をまとめて削除すべく、先頭から10文字以外を削除するコマンドがあればそれも付け加えたいです。
|
19
20
|
|
20
21
|
```Bash
|
1
コメントを受けて追記
answer
CHANGED
@@ -13,4 +13,10 @@
|
|
13
13
|
また、「ファイル名中の全ての`A`を`B`に変える」のでなく、「ファイル名中の最初の`A`を`B`に変える」でいいなら、`rename`コマンドが使えます。`-n 1 -p`は1ファイルずつ確認するためのオプションです。
|
14
14
|
```Bash
|
15
15
|
find [Directory] -type f | xargs -n 1 -p rename A B
|
16
|
+
```
|
17
|
+
#追記
|
18
|
+
> そして、"yyyy年mm月dd日あああ"のような無駄な文字列をまとめて削除すべく、先頭から10文字以外を削除するコマンドがあればそれも付け加えたいです。
|
19
|
+
|
20
|
+
```Bash
|
21
|
+
find [Directory] -type f | while read f;do mv -i $f ${f:0:4}-${f:5:2}-${f:8:2};done
|
16
22
|
```
|