Copy an image and save as new name in different folder - batch-file

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

Related

batch script can't copy fine in a folder containing a space

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"

How do I remove an Error.error file being created and cannot be deleted?

How do I delete/remove the "Error.error" file when the system says it is not there but it is?
The Error.error file was created somehow and I do not know why or how. However, the issue is the system has created this 0 byte file called "Error.error" and it cannot be deleted, even if I try a "permanent" delete command. It also will not allow me to delete any of the folder directory hierarchy in which is resides. When I do try create it, rename it, or create a physical file with the same name and extension, or try to delete this file directly or indirectly I receive the following error message:
"Could not find this item: This is no longer located in C:\maps\test. Verify the items location and try again." Then it list "Error.error" and its information. However, it is there visually.
Any thoughts or suggestions on how to remove or correct?
Thanks!
I had a very similar issue not too long ago where I had a file that was created by another program and whenever I tried to access or delete it, windows would give an error message like "...This is no longer located in...".
If you're having the same problem I was, here's how I got rid of the file. Start a command prompt. In the command prompt, enter a command like del "\\?\<full path to file>". So if your file name is "Error.error" and it is located in the folder "C:\maps\test", the command you would enter is
del "\\?\C:\maps\test\Error.error"
You can delete a folder that windows won't let you access in a similar way by changing the command from "del" to "rd /S".
If you don't know how to start a command prompt, simply click the start button and type "command". The start menu should offer an option named something like "Command Prompt - Desktop app". That's what you need to start.
I found a good explanation of what the "\\?\" means here.

Issues Using Wildcard in Batch-script to Copy a Variable File Name

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).

write contents of one file to another file in the same folder in nsis

I need help writing contents of one file to another in NSIS.
I have two files config1.config and config2.config with default settings in the same folder.I just want to clear contents of config2.config file and write all contents of config1.config to config2.config.
I am getting error in below code
File /oname=c:\DataSubmissionToolFinal.war DataSubmissionToolFinal.war
Please let me know the solution.
If you just want to copy all the contents of one file into another file in the same directory, following should work for you:
Section ""
Delete "config2.config" ; deletes the previous config2.config
Copyfiles "config1.config" "config2.config"
SectionEnd
And
What are you trying to do in this?
File /oname=c:\DataSubmissionToolFinal.war DataSubmissionToolFinal.war
And what error are you getting?

How do I copy existing files and create a duplicate files using xcopy?

I can't seem to find a way to copy an existing file but I do not want to let the previous file with the same name get overwritten. Let say I want to copy data.txt from various pc's by using batch file but I do not want "data.txt" gets overwritten, instead is there a way for the command to generate automated filename to avoid it from overwritten?
You can use the "/-y" switch to confirm before copying a duplicate file.
/-y : Prompts to confirm that you want to overwrite an existing
destination file.
The entire list of switches can be found here

Resources