3

I need to make a .bat file for many people that would be placed in a specific folder and then move specific files from said folder to another folder above the current working directory.

I don't have the paths of where they have said folders, I need to use relative commands.

I know how to move files to lower directories, but don't know how to move them to higher ones.

Here's what I managed (no skills needed, I know) to do that moves files to lower directories.

mkdir "Oudated-do-not-move"
move ThaLuru.shader %cd%/"Oudated-do-not-move"
move DeLin.shader  %cd%/"Oudated-do-not-move"

the list of "move..." lines is way larger but not needed here.

However, I do not know how to make the folder above current folder. At all.

For a test, after making the folder manually, I tried the following option to move file: move DeLin.shader ../"Oudated-do-not-move" - it works.

But I do not know how to make the folder with batch file instead of manually.

I tried these:

mkdir ../test
mkdir %cd%/../test
mkdir %cd%/test

1 Answer 1

11

Your problem is in using / (forward slash) instead of \ (back slash)

For DOS directories should all be separated by \ and for me the following works:

mkdir ..\test

There are some places where / is accepted and works, which can make it seem like it should work everywhere, but the "standard" should be \ in most places.

From Why does Windows use backslashes for paths and Unix forward slashes? (emphasis mine)

/ it is recognized by most programmer-level APIs (in all versions of DOS and Windows). So you can often, but not always get away with using / as a directory separator under Windows. A notable exception is that you can't use / as a separator after the \\? prefix which (even in Windows 7) is the only way to specify a path using Unicode or containing more than 260 characters.

4
  • Would never figure that out, thank you very much. Googling stuff like "how to move files" works, but would never have an idea to look specifically for problem with slashes. Thanks <3 Commented Sep 3, 2023 at 15:53
  • Yeah, it's one of those things that easily catches you out when coming from Linux or other systems which use / because it works a lot of the time, and doesn't really give you an idea why when it doesn't work. In Windows / historically was more used for command switches.
    – Mokubai
    Commented Sep 3, 2023 at 16:01
  • The / is not recognized as a path separator in any version of MS-DOS AFAIK. It is only a path separator on NT based versions of Windows. You can get away with using them in cmds.exe and likewise batch files if you put the path in quotes.
    – PC Luddite
    Commented Sep 4, 2023 at 18:42
  • I went in depth on this on Stackoverflow a few years back
    – PC Luddite
    Commented Sep 4, 2023 at 18:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .