Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BATCH file asks for file or folder [duplicate]

I have a simple copy from to script for one of our guys who's missing a file 20km from my desk

when testing the script out I am prompted if my file shapes.atc is a file or a folder

I can tell you that its a file but how can I autocopy it over my guy needs to be able to just click the batch finished

xcopy /s/y J:\"My Name"\"FILES IN TRANSIT"\JOHN20101126\"Missing file"\Shapes.atc C:\"Documents and Settings"\"His name"\"Application Data"\Autodesk\"AutoCAD 2010"\"R18.0"\enu\Support\Shapes.atc 
like image 298
just me Avatar asked Nov 26 '10 07:11

just me


People also ask

How do I stop xcopy asking file or directory?

Press F if you want the file or files to be copied to a file. Press D if you want the file or files to be copied to a directory. You can suppress this message by using the /i command-line option, which causes xcopy to assume that the destination is a directory if the source is more than one file or a directory.

What does %% mean in batch file?

Represents a replaceable parameter. Use a single percent sign ( % ) to carry out the for command at the command prompt. Use double percent signs ( %% ) to carry out the for command within a batch file. Variables are case sensitive, and they must be represented with an alphabetical value such as %a, %b, or %c. ( <set> )


2 Answers

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* 

The echo f | xcopy ... trick does not work on localized versions of Windows, where the prompt is different.

like image 68
Govert Avatar answered Sep 17 '22 14:09

Govert


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 
like image 27
CharlesB Avatar answered Sep 20 '22 14:09

CharlesB