Skip to main content

What is wrong with this batch file code?

Here is the code: @ECHO ONset drive=%cd:~0,3%xcopy *.jpg “%drive%folder /s /y /q” xcopy *.jpeg “%drive%folder /s /y /q”cmdIt looks for the folder “folder” in the f drive. The folder is there. How come I am getting this error? Is there a cmd to create a folder?

3 Answers

L
Lorine Rath

Feb 20, 2025

This command:set drive=%cd:~0,3%get THREE characters of the directory; for example F:When you put %drive%folder there are two back-slash characters: F:folderuse set drive=%cd:~0,2% or omit the in xcopy’s: %drive%folderAlso, the quotes should enclose just the folder name, not the switches:xcopy *.jpg “%drive%folder” /s /y /qRegards…—————————————————————-EDIT:The cause: I bet you start your Batch file in a folder located INSIDE or in THE SAME “%drive%folder”. You can’t do that!The explanation: When you use /S switch in xcopy, the source files must be in a folder in ABOVE LEVEL with respect to the destination; otherwise, after created a folder and copy it, the process should go into this folder and copy it again in a never-ending process.Regards…... Show More
L
Lorine Rath

Feb 20, 2025

https://shorturl.im/rT0wIthe big problem I see is that you can’t multiply floating point numbers in batch. in other words, you can only multiply integers. example: set weight=%userin%*”0.454″ You have 0.454 being multiplied by another number. Can’t be done in dos. BUT… if you wanted to multiply 454 buy it, and then at the end divide by 1000, you could do that. But there’s another thing wrong with your code: set weight=%userin%*”0.454″ should be: set /a weight=%userin% * 454 Don’t forget to include the /a.... Show More

Want to answer this question?

Join our community to share your knowledge!

Categories

Tags

Related Questions

10
What is wrong with this sentence: “I apologize to disturb you.”?

Please correct the grammar if it’s wrong and do tell me why. Thank you!

7
What is x divided by 2?

I am blanking out right now...x/2 without know x's value? Cannot use x over 2 because it is for an inequality.

10
what is x times 1/2x?

can you help me simplify this?thanks!will choose a best answer 🙂

3
What is Xenocin (from the Nicki Minaj song, Roman’s Revenge)?

Hey guys, I heard in nicki minaj song her saying “i got bars, Xenocin” (i already know she actually said sentincing) But...

6
what is yes in korean?

is it “ye” or “de”

9
what is your means of transportation?

I need help filling this job application ” what is your means of transportation to work?” So i guess its asking how ill...

4
What is Zuka in Japanese Culture?

I've heard on Ouran when the Zuka club came, and I heard it on Lucky Star during the Culture Fest and one the classes wa...