S
S
Sergey Rudnev2014-01-26 12:48:01
bash
Sergey Rudnev, 2014-01-26 12:48:01

How to search for a file in a folder and replace a character in the name?

There is, say, a bunch of files (> 80) of the form:

american-nut-520x300.jpg
american-nut-620x300.jpg
american-nut-750x400.jpg
american-nut-80x80.jpg
american-nut-900x300.jpg
american-nut-908x1024.jpg
american-nut-
960x250.jpg -nut-960x460.jpg
american-nut-960x570.jpg
american-nut.jpg

The task is to rename not the entire name, but a specific letter. In our case, you need to remove the “th” symbol and put “and” instead. How to do it?
bash environment. If additional installation is required. PO, don't worry.
Many thanks in advance for any answer.
// please do not pay attention to spelling errors in file names. :-)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
E
egor_nullptr, 2014-01-26
@sergeyrudnev

Here is the text of the script:

#!/usr/bin/env bash
for fname in `ls`; do
    new_name=`echo $fname | sed s/й/и/g`
    mv $fname $new_name
done

Write it to a file (for example, do.sh), give the right to execute chmod +x do.shand run in the directory with the ./do.sh.

A
Alexey, 2014-01-26
@ScorpLeX

admins.su/massovoe-renamenovanie-fajlov-v-linux

A
Andrey Gurtovoy, 2014-01-28
@jt3k

or you can use something like https://apps.ubuntu.com/cat/applications/precise/s...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question