#!/usr/bin/perl use strict; use warnings; use File::Find; my $dir = "/home/ivan/M1"; find(\&wanted, $dir); sub wanted { my $file = $_; # storing unprocessed filename $_ =~ s/ /_/g; # replacing spaces with _ rename "$File::Find::dir/$file", "$File::Find::dir/$_"; # renaming files } #### Can't cd to (/home/ivan/M1/) Some Dirname With Spaces: no such file or directory at ./1.pl line 16