R
R
ralaton1212017-08-15 10:19:43
linux
ralaton121, 2017-08-15 10:19:43

How to recursively change the extension of files in Unix?

It is necessary to rename a mountain of files lying in subdirectories nested in subdirectories.
Linux (bash) and FreeBSD (csh) systems.
The extension is exactly the same (and the same). We also change to exactly the same thing. Without any additional conditions.
How?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
R
Roman Mirilaczvili, 2017-08-15
@2ord

An example to rename all .bak files to .old files in nested directories:
Note: For debugging purposes, rename commands will be printed to the screen due to the presence of the echo command.
After debugging, you can remove echo from the command and then the renaming of the files will actually be performed.
Read the manuals:
man find
man rename

R
res2001, 2017-08-15
@res2001

see find -exec

D
Derevyanko Alexander, 2017-08-16
@dio4

#меняет 1.mp3 и тд на 01.mp3 и тд. в каталоге ./renamed если sed слишком сложно... 
#!/bin/bash
#cd ~
mkdir -p renamed
j=1
for i in *.mp3 
do 
  cp $i ./renamed/"0"$j".mp3"
  let j=$j+1
done

V
Victor Taran, 2017-08-17
@shambler81

geeksmagazine.org/post/327/kak-pereimenovat-neskol...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question