MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: MOVE/EXPORT FILES AT ONCE

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100112] Re: MOVE/EXPORT FILES AT ONCE
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Mon, 25 May 2009 06:16:11 -0400 (EDT)

On 5/22/09 at 11:40 PM, alain.mazure at oamp.fr (Alain Mazure) wrote:

>How is it possible to move, at once, to e.g another directory ,
>files identified with e.g:

>FileNames["*.dat"]

>I.e, what is the equivalent of the classic cp *.dat and better the
>equivalent of cp *.*  ?

This task is probably more efficient to do outside of
Mathematica. But it can be done inside Mathematica. For example

CopyFile[#,ToFileName[directoryName,#]&/@FileNames["*"]

will copy all of the files in the current working directory to
the directory specified by directoryName. Note, the syntax I've
used above assumes no sub-directories exist in the current
working directory. If this is the case, an error will be
generated since CopyFile doesn't operate on directories. A more
robust solution would be

CopyFile[#,ToFileName[directoryName,#]&/@DeleteCases[FileNames["*"],_?(File=
Type===Directory&)]




  • Prev by Date: Re: Re: Integrate Bug
  • Next by Date: Dynamic performance - input fields slow
  • Previous by thread: Re: MOVE/EXPORT FILES AT ONCE
  • Next by thread: Apply function breaks Parallelize?