1

I want to rename all files ( could be also one file ) under dir directory so each file under dir will added with the name “old_” before each file

Remark – I can do the rename with loop and mv each file to the new file name But I prefer to do that with one command – is it possible?

when we need to rename one file is very simple

    mv dir/file  dir/old_file

but how to do the same when we have 100 files?

example

under dir I have

file1
file2
file3

what I want is

old_file1
old_file2
old_file3

OR

dse.txt
uytee.txt
drjf4.txt

convert to

old_dse.txt
old_uytee.txt
old_drjf4.txt
maihabunash
  • 1,632
  • 9
  • 34
  • 60
  • 1
    There's the `rename` command line tool which takes a perl expression such as `s/^/old_/` to apply to a number of files. – knittl Sep 03 '14 at 06:36
  • There are a myriad (well, several) questions on the subject — see the list of related questions on the right. There's a Perl-based `prename` (sometimes installed as `rename`) that will do the job admirably. – Jonathan Leffler Sep 03 '14 at 06:37
  • can you give here real example ? ( see my new update - file can be with diff name ) – maihabunash Sep 03 '14 at 06:38

0 Answers0