Currently I'm using the code below to try and make a batch file to automatically copy the file to my 'test location' folder.
xcopy "C:\Users\MyComputer\Desktop\Excel.xlsx" "C:\Users\MyComputer\Desktop\test location\Excel.xlsx"
However it doesn't seem to be working. I picked up the code online and made my own modifications. Am I missing something?
Double-check the name of your destination folder to make sure you aren't missing an underscore or something. Then try removing \Excel.xlsx from the end of your destination specification and see if it works:
xcopy "C:\Users\MyComputer\Desktop\Excel.xlsx" "C:\Users\MyComputer\Desktop\test location"
Related
I have the following batch code
copy H:\test\Folder\sample.ini H:\test\sample.ini
Pretty straight forward. However, it doesn't work if I modify the code to look in "New Folder" instead of "Folder".
In other words, I get a "file cannot be found error" if the directory structure contains a space. How can I resolve this?
it Doesn't work because there is a space in your Directory name(i.e New Folder) and it confuses windows interpreter,so all you have to do is add "" around your path.the following code should do your job:
COPY /Y "H:\test\New folder\sample.ini" "H:\test\sample.ini"
I have an image. Say its
Cutedoggo.png which is sitting on my desktop
I would like to copy it over, rename it , and save it to a new destination. Let's say I want to rename it to Dog1.png in the c:/doggo folder I've made
I tried in windows command prompt (while inside the directory of original file)
copy CuteDoggo.png Dog1.png c:/doggo but it didn't work. Error message
error: the syntax of name is incorrect
how would I accomplish this using command prompt?
copy "CuteDoggo.png" "c:\doggo\Dog1.png"
also this works as well: (simplified)
copy CuteDoggo.png c:\doggo\Dog1.png EDIT this will not work if there's a space in folder.
courtesy of stephan
My Process:
For version control, all my files are named with the format "fileName_v#.#"
I keep a folder called 'Live Environment', and as a new version is rolled out, the current file (ex. fileName_v1.0) is removed from 'Live Environment' folder, and the new version (ex. fileName_v2.0) is moved into 'Live Environment'.
My batch script is used to keep all users on the most current version. It works perfect, except with every version I need to go back and update the hard-coded file name in my script to the new file name.
I would like to use a wildcard to search this folder for whatever file is in the 'Live Environment' folder, and then perform the copy function.
Current Code:
::Sets the default install location as the user's desktop
set "DestinationFolder=%userprofile%\desktop"
::Copies and saves file to the user's Desktop
copy /-y "\\myUNCPath\Live Environment\fileName_v*.accdb" "%DestinationFolder%\copiedFile.accdb"
My Issue:
I've hardcoded the "fileName_v#.#.accdb" in for each version so far, and the code executes perfectly. The second I remove the hardcoded file version and add the "*" wildcard, the code errors. The copy function still runs, but simply creates an empty .accdb file on the users desktop, which when used gives the error:
"Unrecognized database format"
At this point I'm overthinking this and making it harder than it needs to be. A set of fresh eyes on the issue would be helpful. Any help would be greatly appreciated!
#aschipfl - that worked! Thanks for the comment.
Simply adding "/b" to the copy line fixed the issue.
copy /-y /b
(For more details see the aschipfl's comment posted below the question).
I'm trying to write a small bat script to put on my teams desktops and allow them to update their personal macro file with mine when ever I push out an update or have created new tools.
I have the following
xcopy "O:\abc Supply chain\Supply Chain Team\David Peters\Excel\Macro File" "%AppData%\Roaming\Microsoft\Excel\XLSTART\" /y
under CMD is says 1 files copied yet there isn't anything in the XLSTART folder.
can you pleased tell me what I'm doing wrong
many thanks
Not sure about your configuration, but for me the Roaming folder is already included in the value of the %AppData% variable.
"%AppData%\Roaming\Microsoft\Excel\XLSTART\"
^......^
So, probably you should use "%AppData%\Microsoft\Excel\XLSTART\"
I have a batch file I've created which uses xcopy to copy a dir, and child dirs, and merge them into one file. (ie. all my modulised development css stylesheets merged into one production stylesheet).
Everything is good, apart from the fact that when I reference the excludelist.txt, it only excludes the first line, and not the subsequent files I want excluded.
Anyone fancy a crack at this? You'd be most helpful.
Here's the code:
XCOPY C:\xampp\htdocs\PROJECT\css\*.* C:\temp /S /I /Y /EXCLUDE:C:\xampp\htdocs\PROJECT\exclude.txt
...and inside my exclude.txt is...
1.css
2.css
3.css
4.css
5.css
///// I know the code works (to an extent) because it is infact excluding file 1.css -- just not the ones below it. Am I right to put each exclusion on a new line?
I use the following,
xcopy "C:\users\dad\*.*" dad /s /d <yesnoyesno /EXCLUDE:excluexclu 1>cop.txt 2>err.txt
as somewhere on the web I saw a note to the effect that the /Y switch could not be used directly with an exclude file.
What I wanted to point out here, was the useful output files 1 & 2, which detail the success & failure issues.
Mine shows only success.
The short answer: Create a new text file, type the entries and save the file.
The longer explanation: I ran into this very issue on a Windows 2008 server today. I tried all kinds of things to get it to work. Forced notepad to save the file as ANSI, Unicode and UTF-8 but all of them had the same problem. Finally I started thinking about the fact that I put the file on the server via FTP and it's quite likely that FTP tweaked the file format. I created a new text file on the server, typed all the same entries in the new file and now it works.
I had a similar problem. I was trying to exclude all files with a certain extension in the root folder and any sub-folders and it didn't work. The reason was I was putting *.pdb instead of just .pdb. The newline/carriage return thing was a total red herring for me.
So my file just looked like:
.pdb
.obj
.vb
.cs
You seem to be using xcopy correctly - each exclusion file (or match depending on wildcards) should be on a new line within the file. So far I've been unable to reproduce the behaviour you're experiencing.
Is the exclude.txt listing you've given above a test file, or are they the actual css names?
What are the names of the other files that your batch file is supposed to copy?
Edit:
That the xcopy is failing to exclude further files after a single match is giving me most pause. I thought it might be to do with the type of carriage-return that was used in the exclude file, but xcopy handles unix-style carriage-returns just fine.
Can you re-verify that the correct exclude file is being used?
Try forcing it to save with ANSI encoding on your text editor.
I was having a similar issue and that did it.