ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: how can I copy a directory of files to lower case equivalents?
Date Tue, 02 Oct 2007 12:16:06 GMT
sorry forgot one line, the first post renames dirnames also,
so one has to use =

<script language="ruby">
<![CDATA[
require 'fileutils'
require 'find'

srcdir=$srcdir
destdir=$destdir
   
Dir.mkdir(destdir) unless File.exists?(destdir)
Dir.entries(srcdir).each do | i |
  if i !='.' && i !='..'
    FileUtils.cp_r Dir["#{srcdir}/**"], destdir
  end
end

Find.find(destdir) do |file|
  unless File.directory?(file)
    File.rename(file,file.downcase)
  end
end
 ]]>
 </script>


the line =
unless File.directory?(file) prevents dirnames from
renaming

Regards, Gilbert 



-----Original Message-----
From: Rebhan, Gilbert [mailto:Gilbert.Rebhan@huk-coburg.de] 
Sent: Tuesday, October 02, 2007 2:12 PM
To: Ant Users List
Subject: RE: how can I copy a directory of files to lower case
equivalents?


Hi,

-----Original Message-----
From: Alx G [mailto:glubbah@yahoo.co.uk] 
Sent: Tuesday, October 02, 2007 1:10 PM
To: user@ant.apache.org
Subject: how can I copy a directory of files to lower case equivalents?

/*
Hi,

Does anyone know if there's anything in Ant that can copy files from a
directory to another directory but change all the file names to lower
case?
*/

here's a solution with <script> and ruby =

----------------snip----------------

<project name="bla" default="main" basedir=".">

<!-- // Properties -->
<property name="srcdir" value="Y:/test"/>
<property name="destdir" value="Y:/test_"/>
<!-- Properties // -->

<target name="depends">
  
<script language="ruby">
<![CDATA[
require 'fileutils'
require 'find'

srcdir=$srcdir
destdir=$destdir
   
Dir.mkdir(destdir) unless File.exists?(destdir)
Dir.entries(srcdir).each do | i |
  if i !='.' && i !='..'
    FileUtils.cp_r Dir["#{srcdir}/**"], destdir
  end
end

Find.find(destdir) do |file|
  File.rename(file,file.downcase)
end
 ]]>
 </script>

</target>

<target name="main" depends="depends">
<echo>
  
### Copy / Rename ###
src    = ${srcdir}
target = ${destdir}

</echo>
</target>
</project>

----------------snip----------------


Regards, Gilbert



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message