Copying a file (in relative position) with .bat
Solved
Azep65
Posted messages
10
Status
Membre
-
Azep65 Posted messages 10 Status Membre -
Azep65 Posted messages 10 Status Membre -
Good evening, I would like to copy a (or multiple) file(s) using a .bat command
My problem is that this .bat must be in a folder of a game and thus the path is not fixed. Is it really possible to do this or is it mandatory to have the full path?
Here is my game folder:
Minecraft2D\Maps\niveaux.lvl
to copy to
Minecraft2D\niveaux.lvl
Looking forward to any response, thank you all!
My problem is that this .bat must be in a folder of a game and thus the path is not fixed. Is it really possible to do this or is it mandatory to have the full path?
Here is my game folder:
Minecraft2D\Maps\niveaux.lvl
to copy to
Minecraft2D\niveaux.lvl
Looking forward to any response, thank you all!
8 réponses
Hello,
Ideally, we would need the full path.
Here's the content of the .bat
@ECHO OFF
xcopy X:\Minecraft2D\Maps\niveaux.lvl Y:\Minecraft2D\niveaux.lvl /m /e /y
/m = copy only the updated files
/e = copy all subdirectories
/y = prompt for confirmation before overwriting
If there are spaces in the folder/file names, you need to use ""
xcopy "c:\source game" "x:\destination game" /m /e /y
--
Greetz from
Dj Dakta
Ideally, we would need the full path.
Here's the content of the .bat
@ECHO OFF
xcopy X:\Minecraft2D\Maps\niveaux.lvl Y:\Minecraft2D\niveaux.lvl /m /e /y
/m = copy only the updated files
/e = copy all subdirectories
/y = prompt for confirmation before overwriting
If there are spaces in the folder/file names, you need to use ""
xcopy "c:\source game" "x:\destination game" /m /e /y
--
Greetz from
Dj Dakta
Thank you for the additional information!
Thanks djdakta, it's working well but I can't move the game's folder.
Do you think it's possible?
Otherwise, I was thinking of coding an app in C to create and copy the contents of the files.
The advantage is that the path can be based on the position of the .exe, but it's quite time-consuming to code..
I'll try all that and get back to you, thanks for your help.
Thanks djdakta, it's working well but I can't move the game's folder.
Do you think it's possible?
Otherwise, I was thinking of coding an app in C to create and copy the contents of the files.
The advantage is that the path can be based on the position of the .exe, but it's quite time-consuming to code..
I'll try all that and get back to you, thanks for your help.
Uhm... Do you want to copy the game folder elsewhere, or do you simply want to move it?
Maybe a silly question, but why are you so keen on having this folder copied/moved?
Isn't it fine where it is? ;-)
--
Greetz from
Dj Dakta
Maybe a silly question, but why are you so keen on having this folder copied/moved?
Isn't it fine where it is? ;-)
--
Greetz from
Dj Dakta
To move a folder or file(s):
MOVE [drive:] [path]filename destination
To rename a folder:
MOVE [drive:] [path]oldfoldername newfoldername
--
Greetz from
Dj Dakta
Thank you, but that doesn't really solve my problem:
Basically, the game uses and modifies the files, so I'm looking to create a reset system.
Some files are placed in a master folder; they serve as originals (and will never be modified). Then, in another folder, there are the files modified by the game (child folder). The .bat file should COPY the master files into the child folder to replace and reset the files to their original state. Resetting them to zero (but not empty files).
I hope this explanation is more precise.
For now, it's working, but I can't move the game because the full path changes.
It may be impossible to do this with a .bat; I'm looking to do this in C, and I know it's possible, but it will take me some time to start.
I'll get back to you as soon as possible; thank you!
Basically, the game uses and modifies the files, so I'm looking to create a reset system.
Some files are placed in a master folder; they serve as originals (and will never be modified). Then, in another folder, there are the files modified by the game (child folder). The .bat file should COPY the master files into the child folder to replace and reset the files to their original state. Resetting them to zero (but not empty files).
I hope this explanation is more precise.
For now, it's working, but I can't move the game because the full path changes.
It may be impossible to do this with a .bat; I'm looking to do this in C, and I know it's possible, but it will take me some time to start.
I'll get back to you as soon as possible; thank you!
Hello
Here's a lead:
https://stackoverflow.com/questions/14936625/relative-path-in-bat-script
https://www.developpez.net/forums/d1504346/general-developpement/programmation-systeme/windows/scripts-batch/chemin-relatif-absolu/
Light a fire for someone and they will be warm for the rest of the day. Set a man on fire and he will be warm for the rest of his life.
-Terry Pratchett-
Here's a lead:
https://stackoverflow.com/questions/14936625/relative-path-in-bat-script
https://www.developpez.net/forums/d1504346/general-developpement/programmation-systeme/windows/scripts-batch/chemin-relatif-absolu/
Light a fire for someone and they will be warm for the rest of the day. Set a man on fire and he will be warm for the rest of his life.
-Terry Pratchett-
/i
If the Source parameter refers to a directory or contains wildcard characters and the Destination parameter is not specified, the xcopy command assumes that the name of the destination directory is destination and a new directory is therefore created. All files are then copied into this new directory. By default, the xcopy command prompts the user whether the destination is a file or a directory.
If the Source parameter refers to a directory or contains wildcard characters and the Destination parameter is not specified, the xcopy command assumes that the name of the destination directory is destination and a new directory is therefore created. All files are then copied into this new directory. By default, the xcopy command prompts the user whether the destination is a file or a directory.