Skip to main content
Handling (too) many files in the directory
Source Link
Chris Davies
  • 128.3k
  • 16
  • 179
  • 324

At the shell, if you've got the Perl rename installed (sometimes called prename):

rename -v 's/$/.bad/' * 

InIf you have too many files for the shell * glob to handle them all you can mix'n'match with find like this (also replace + with \; if necessary):

find . -maxdepth 1 -exec rename -v 's/$/.bad/' {} + 

For Perl, just use move from a standard module:

use File::Copy; for (<*>) { move($_, "$_.bad"); } 

At the shell, if you've got the Perl rename installed (sometimes called prename):

rename -v 's/$/.bad/' * 

In Perl:

use File::Copy; for (<*>) { move($_, "$_.bad"); } 

At the shell, if you've got the Perl rename installed (sometimes called prename):

rename -v 's/$/.bad/' * 

If you have too many files for the shell * glob to handle them all you can mix'n'match with find like this (also replace + with \; if necessary):

find . -maxdepth 1 -exec rename -v 's/$/.bad/' {} + 

For Perl, just use move from a standard module:

use File::Copy; for (<*>) { move($_, "$_.bad"); } 
Source Link
Chris Davies
  • 128.3k
  • 16
  • 179
  • 324

At the shell, if you've got the Perl rename installed (sometimes called prename):

rename -v 's/$/.bad/' * 

In Perl:

use File::Copy; for (<*>) { move($_, "$_.bad"); }