copy command in DOS is not recognizing when filename has '=' - batch-file

I wrote batch script to copy a file and write a log.
However copy is not working when the file name is like this:
8001#121122213500#1002#00#M=MRN100#C=Test_Large_File2.wav
On further checking I found this is because of the = in the filename.
I also tested individually. When I use copy *.wav d:\wav file is getting copied, but when I use
copy 8001#121122213500#1002#00#M=MRN100#C=Test_Large_File2.wav d:\wav
I get an message that the file is not found.
Can any one help me in resolving this. I also tried searching old posts here but couldn't find any.
Thanks

You need to quote the filename
copy "8001#121122213500#1002#00#M=MRN100#C=Test_Large_File2.wav" d:\wav

Related

Copy an image and save as new name in different folder

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

How to copy the names of the subfolders in a folder, so to use them in a batch program (command line)?

I need to check the files of a versioned system. To do that, I need to write a batcha program so to compare the contents of several folders containing the repositories.
So, my question is: how can I "read" the names of all the subfolders inside a folder, so to use these names later to find subfolders having the same names in a different repositories?
I suppose I may use DIR to print on the screen a list of these names but I don't know how to write it on a text file and then read it. Moreover, I should edit this kind of list, anyway.
Any suggestions or new ideas to solve this problem?
I thank gratefully who ever will answer.
it seems that you can get the subfolders using batch file from perl as follows:
system("start C:\\Temp\\mybatchfile.bat");
or you might try to pass your command suggested by #Stephan straight to system and try to handle what it is returned.

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

Copy and rename XLSX file using batch script

I have many XLSX files that I will need to copy to a new location and rename. The Excel files appear to be copied to the new location, but when I open them, I keep getting the "found unreadable content" error message, and all the data is gone.
I use an asterisk to find the file, and then I want to rename it so that it doesn't have the date string.
This is the code I'm using:
set OrigLocn=C:\OldLocation\
set NewLocn=C:\NewLocation\
copy "%OrigLocn%S5820-003-terms-sg*" "%NewLocn%S5820-003-terms-sg.xlsx"
copy "%OrigLocn%S5921-293-terms-addp*" "%NewLocn%S5921-293-terms-addp.xlsx"
copy "%OrigLocn%S5921-293-terms-sg*" "%NewLocn%S5921-293-terms-sg.xlsx"
copy "%OrigLocn%S5921-349-terms-addp*" "%NewLocn%S5921-349-terms-addp.xlsx"
I would use the xcopy command to copy over multiple files then use REN to change the name.
XCOPY: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
REN: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
change copy to copy /b. This copies in binary mode but the default is ascii mode which terminates the copy when certain binary sequences are encountered.
Using the wildcard in the copy command will cause the target file to be concatenated if more than one file matches the filespec.
if this is the case then you'll need different code to remove the date string.

Resources