Reputation: 21
I'm trying to move a file from the folder the batch file is in to a folder on the C:\
drive, and I just can't figure out how.
I tried using dir
to get the parent folder, but it registered an error.
What would I use?
move dir\test.bat C:\Some folder
Upvotes: 2
Views: 15131
Reputation: 2473
You must use backslashes \
as path separators. According to your comment you used forward slash /
in source path.
Upvotes: 0
Reputation: 77677
To reference a file or a folder relative to the location of the batch script you need to use the %0
parameter and the ~dp
combined modifier. The following moves the file somefile.txt
to Some folder
on C:
:
MOVE "%~dp0somefile.txt" "C:\Some folder"
Upvotes: 0
Reputation: 1087
This may be a permissions issue for the path you're trying. Try opening the command line as an administrator (right click -> run as administrator)
This works fine for me when the batch file is run from the directory that the test file is in:
move "test.txt" "C:\Test"
Upvotes: 1