in reply to File::Find and replacing spaces in filenames.
#!/usr/bin/env perl6 use v6; # Substitute special chars to underscore my token special_char { <[ \s \( \) ]> }; multi MAIN( Str $filename where ( $filename.IO ~~ :f and $filename.match( &special_char ) ) ) { $filename.IO.rename( $filename.subst( /<special_char>/ , '_', :g) +); } multi MAIN( Str $filename where ( $filename.IO ~~ :f and ! $filename.match( & +special_char) ) ) { say "File '$filename' has no spepcial characters"; } multi MAIN( Str $filename where !($filename.IO ~~ :f) ) { say "File '$filename' does not exist"; } sub USAGE() { say "Usage: NoSpace file-name"; }
|
---|