Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to use <strong><a href="http://perldoc.perl.org/functions/rename.html" rel="nofollow noreferrer">rename</a></strong> .</p> <p>Here is it's signature:</p> <pre><code> rename <strong>OLDNAME,NEWNAME</strong> </code></pre> <p>To make it recursive, use it along with <strong><a href="http://search.cpan.org/perldoc?File::Find" rel="nofollow noreferrer">File::Find</a></strong></p> <pre><code> use strict; use warnings; use File::Basename; use File::Find; #default searches just in current directory my @directories = ("."); find(\&wanted, @directories); sub wanted { #renaming goes here } </code></pre> <p>The following snippet, will perform the code inside <strong>wanted</strong> against all the files that are found. You have to complete some of the code inside the <strong>wanted</strong> to do what you want to do.</p> <p>EDIT: I tried to accomplish this task using File::Find, and I don't think you can easily achieve it. You can succeed by following these steps :</p> <ul> <li><p>if the parameter is a dir, capitalize it and obtain all the files</p></li> <li><p>for each file, if it's a dir, go back at the beginning with this file as argument</p></li> <li><p>if the file is a regular file, capitalize it</p></li> </ul> <p>Perl just got in my way while writing this script. I wrote this script in ruby :</p> <pre><code> require "rubygems" require "ruby-debug" # camelcase files class File class &lt;&lt; self alias :old_rename :rename end def self.rename(arg1,arg2) puts "called with #{arg1} and #{arg2}" self.old_rename(arg1,arg2) end end def capitalize_dir_and_get_files(dir) if File.directory?(dir) path_c = dir.split(/\//) #base = path_c[0,path_c.size-1].join("/") path_c[-1].capitalize! new_dir_name = path_c.join("/") File.rename(dir,new_dir_name) files = Dir.entries(new_dir_name) - [".",".."] files.map! {|file| File.join(new_dir_name,file)} return files end return [] end def camelize(dir) files = capitalize_dir_and_get_files(dir) files.each do |file| if File.directory?(file) camelize(file.clone) else dir_name = File.dirname(file) file_name = File.basename(file) extname = File.extname(file) file_components = file_name.split(/\s+/) file_components.map! {|file_component| file_component.capitalize} new_file_name = File.join(dir_name,file_components.join(" ")) #if extname != "" # new_file_name += extname #end File.rename(file,new_file_name) end end end camelize(ARGV[0]) </code></pre> <p>I tried the script on my PC and it capitalizes all dirs,subdirs and files by the rule you mentioned. I think this is the behaviour you want. Sorry for not providing a perl version.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload