Girardelli, Erin E wrote:
> I can't figure out how to rename a file using the move task.  I have a
> zip file that I know the directory location of, but I don't know the
> entire name of the file.  So, I just need to find the single zip file in
> the directory and rename it.  At the command line, I can do this:
>
>       move C:\test\BetaRelease*.zip C:\test\Prod\ProductionRelease.zip
>
> For whatever reason, move won't work from the exec task, and the move
>   
> task won't allow a * in the file name.  If I try the following I get an
> error:
>
>       <move file="C:\test\BetaRelease*.zip"
> tofile="C:\test\Prod\ProductionRelease.zip" overwrite="true" />
>
> I can't use <fileset> within the move task because move will only accept
> the 'todir' option and not the 'tofile' option.
>   
Move won't work from the exec task because it's handled by the DOS 
shell, which is cmd.exe.  You could do it that way, by using cmd.exe as 
the program file name, and being sure to pass /C first so that the shell 
terminates.  For example, <exec program="cmd.exe" commandline="/C move 
C:\test..." should work. 

You can also do it within NAnt.  Use the <foreach> task with 
item="File", and using <in><items><include ... This will find the file 
name, which you can then pass to the <move> command.  This will also 
give you an opportunity for some error checking, specifically making 
sure you have exactly one matching source file.

But let me ask this:  Where did the BetaRelease*.zip file come from?  
Someone had to give it a full name.  Can't that work also be put into 
NAnt, which would make the whole problem moot?

Gary



-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
NAnt-users mailing list
NAnt-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nant-users

Reply via email to