3 Replies Latest reply: Jun 14, 2017 6:41 AM by Graham Cooper RSS

    Copying and renaming an excel file

    Graham Cooper



      I am attempting to achieve the subject line.


      My current script is as below, what am I missing?  It executed but nothing happens.


      //COPY yesterdays PE2 list to the Archive folder for backup
      execute cmd.exe /c copy $(vDataSourceExcel)SBDCP MICAP Summary Report.xlsx $(vDataSourceBackup)


      I know this won't rename the file but I was doing this step by step, advise on step 2 would also be appreciated.


      Thank You



        • Re: Copying and renaming an excel file
          Graham Cooper

          I've had some success doing things differently.


          I have set a variable with my 2 file locations and file names and run the variable further on in the script as follows:



          execute cmd.exe /C xcopy $(vDataBackup) /Y;


          This works fine apart from the command prompt ops up and forces me to declare a file or directory (F or D).  when U type F it the executed fine and my file is renamed and copied.  However I want to schedule this overnight and don't wish to have to intervene..........thoughts.

            • Re: Copying and renaming an excel file
              Peter Rieper

              Aunt Google found something:


              A seemingly undocumented trick is to put a * at the end of the destination - then xcopy will copy as a file, like so

              xcopy c:\source\file.txt c:\destination\newfile.txt* 





              Actually xcopy does not ask you if the original file exists, but if you want to put it in a new folder named Shapes.atc, or in the folder Support (which is what you want.

              To prevent xcopy from asking this, just tell him the destination folder, so there's no ambiguity:

              xcopy /s/y "J:\Old path\Shapes.atc" "C:\Documents and Settings\his name\Support" 

              If you want to change the filename in destination just use copy (which is more adapted than xcopy when copying files):

              copy /y "J:\Old path\Shapes.atc" "C:\Documents and Settings\his name\Support\Shapes-new.atc