Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Copying and renaming an excel file

Morning,

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

Graham

1 Solution

Accepted Solutions
prieper
Master II
Master II

Aunt Google found something:

quote

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* 

unquote

alternatively

quote

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 
unqote

View solution in original post

3 Replies
Not applicable
Author

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.

prieper
Master II
Master II

Aunt Google found something:

quote

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* 

unquote

alternatively

quote

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 
unqote
Not applicable
Author

Thank You Peter,

It was as easy as just using copy!

Cheers

Graham