Linuxをつかったバッチファイル名変更
久しぶりのLinuxについてのきじです。
Somethings are just really easy to do on linux.
とこどき、大量の画像ファイル名を変更したいときがある。一個一個するのは大変だが、下記のコマンドをつかえば楽です。
This is just one way of renaming an entire batch of files with a one-liner. I use this to batch rename photos.
For example, some NIKON digital cameras affix use
So if we want to change a bunch of files such as,
to
We can just do this:
Got it?
アップデート(Update)
ハワイの友人、CKからのアドバイス:
Some good advice from my good-friend CK@Hawaii,
(MS)DOSの場合このコマンドを実効:ren DSCN*.JPG Sargassum*.JPG
"Seems pretty darn simple to me"
Somethings are just really easy to do on linux.
とこどき、大量の画像ファイル名を変更したいときがある。一個一個するのは大変だが、下記のコマンドをつかえば楽です。
This is just one way of renaming an entire batch of files with a one-liner. I use this to batch rename photos.
For example, some NIKON digital cameras affix use
DSCN0000.jpg, where 0000 is the index number of the photos.So if we want to change a bunch of files such as,
DSCN0001.JPG
DSCN0002.JPG
DSCN0003.JPG
DSCN0004.JPG
to
Sargassum0001.JPG
Sargassum0002.JPG
Sargassum0003.JPG
Sargassum0004.JPG
We can just do this:
ls DSCN* | awk '{print "mv "$1" "$1}'| sed s/DSCN/Sargassum/2|shls DSCN* gets the directory listing and pipes it to,awk '{print "mv "$1" "$1}', which prints out the command to execute, which is "mv", with the ls'ed files repeated twice, which is then piped to,sed s/DSCN/Sargasum/2, which changes the 2nd occurance of DSCN to Sargassum and pipes it to,sh, which is just the shell.Got it?
アップデート(Update)
ハワイの友人、CKからのアドバイス:
Some good advice from my good-friend CK@Hawaii,
(MS)DOSの場合このコマンドを実効:ren DSCN*.JPG Sargassum*.JPG
"Seems pretty darn simple to me"
コメント