LoginSignup
26
28

More than 5 years have passed since last update.

文字化けを起こしたファイルのリネーム方法

Last updated at Posted at 2016-01-19

概要

文字化けしているファイルはファイル名を指定できないのでinode番号でファイルを特定する必要がある

inode番号を確認する

ls

オプション 説明
-l ファイルの詳細を表示する
-i / -inode inode番号を表示する
ls -li
合計 89096
539049 -rw-r--r--. 1 root root 78038486 1月 17 18:14 2016 ?X?b?L??????Java???????H??.zip
656486 drwxrwxr-x. 2 normaluser normaluser 4096 1月 17 18:17 2016 ?X?b?L????????Java?????+?H??

findコマンドのコマンド実行オプションを使ってファイル名変更

find

オプション 説明
-ok cmd \; 検索結果に対してコマンドcmdを実行する(実行前にユーザーに問い合わせする)
-exec cmd \; 検索結果に対してコマンドcmdを実行する(実行前にユーザーに問い合わせしない)
{}     コマンド結果を挿入する位置を指定する
find . -inum 539049 -ok mv '{}' zissen.zip \;
find . -inum 656486 -ok mv '{}' zissen \;

実行結果

ls -l
合計 89096
drwxrwxr-x. 2 normaluser normaluser     4096  1月 17 18:17 2016 zissen
-rw-r--r--. 1 root root 78038486  1月 17 18:14 2016 zissen.zip
26
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
28