diff --git a/dvc/project.py b/dvc/project.py
index 68487ff62..ed1affbe4 100644
--- a/dvc/project.py
+++ b/dvc/project.py
@@ -282,6 +282,8 @@ class Project(object):
         from_out = Output.loads_from(Stage(self, cwd=os.curdir),
                                      [from_path])[0]
 
+        to_path = self._expand_target_path(from_path, to_path)
+
         try:
             stage, out = next((stage, out)
                               for stage in self.stages()
@@ -294,22 +296,26 @@ class Project(object):
         if not stage.is_data_source:
             raise MoveNotDataSourceError(stage.relpath)
 
-        to_out = Output.loads_from(stage, [to_path], out.cache, out.metric)[0]
-
-        with self.state:
-            out.move(to_out)
-
         stage_name = os.path.splitext(os.path.basename(stage.path))[0]
         from_name = os.path.basename(from_out.path)
-
         if stage_name == from_name:
             os.unlink(stage.path)
 
             stage.path = os.path.join(
-                os.path.dirname(to_out.path),
+                os.path.dirname(to_path),
                 os.path.basename(to_path) + Stage.STAGE_FILE_SUFFIX
             )
 
+            stage.cwd = os.path.join(self.root_dir, os.path.dirname(to_path))
+
+        to_out = Output.loads_from(stage,
+                                   [os.path.basename(to_path)],
+                                   out.cache,
+                                   out.metric)[0]
+
+        with self.state:
+            out.move(to_out)
+
         stage.dump()
 
         self._remind_to_git_add()
@@ -1293,3 +1299,8 @@ class Project(object):
                     blue=colorama.Fore.BLUE,
                     nc=colorama.Fore.RESET)
         )
+
+    def _expand_target_path(self, from_path, to_path):
+        if os.path.isdir(to_path) and not os.path.isdir(from_path):
+            return os.path.join(to_path, os.path.basename(from_path))
+        return to_path

dvc move path/to/some.tgz path/to/dir/
👉 dvc 0.23.2 installed via pip on ubuntu

`dvc move path/to/some.tgz path/to/dir/` did something rather strange and unintuitive when I tried to move a file to a destination directory (without re-specifying the destination filename).

I expected it to behave like unix's `mv`, which moves a file into the destination directory while keeping the same name, when a directory (with trailing slash) is specified as the destination, e.g. `mv thing.txt path/to/dir/` results in `path/to/dir/thing.txt`.

So I started with directory structure:
```
data/some.tgz
data/some.tgz.dvc
sub/data/
```

And I ran the command:
```
$ dvc move data/some.tgz sub/data/
```

I ended up with the directory structure:
```
data/.dvc
data/sub/data
sub/data/
```
... which looks kind of like the directory `data/` is now under dvc control, and the `some.tgz` was renamed to `data/sub/data` (a file with no extension).  `du -sh data/sub` shows that `data/sub/data` is of the same file size as the original `.tgz`.

What I expected to end up with:
```
data/
sub/data/some.tgz
sub/data/some.tgz.dvc
```

I think that there are at least a couple bugs here.  

1. It is clear in my syntax that I intended the destination to be a directory.  dvc doesn't seem to handle that syntax.  It would be great if dvc could be updated to support this syntax — or, at the very least, to detect this syntax and give an error message to prevent the current behavior, which I can't imagine is desired.  
1. Might be irrelevant if you fix the first bug, but it seems something weird is happening with the paths here.  How did the destination path (`sub/data/`) get somehow combined with the src path (`data/some.tgz`) to produce `data/sub/data`? 🤔

I was able to get myself out of this miss by `dvc move data/sub/data data/some.tgz`, which resulted in:
```
data/data/some.tgz
data/.dvc
```
Then I renamed `data/.dvc` to `data/data/some.tgz.dvc` and updated its `path` property to `some.tgz`.  Then, finally, I ran `dvc move data/data/some.tgz ../../sub/data/some.tgz`, which is still running now, but I think might get me where I wanted to go in the first place. 🤞 
diff --git a/tests/test_move.py b/tests/test_move.py
index 088eaa07c..8b651cd2d 100644
--- a/tests/test_move.py
+++ b/tests/test_move.py
@@ -6,6 +6,7 @@ from dvc.stage import Stage
 
 from tests.basic_env import TestDvc
 from tests.test_repro import TestRepro
+from tests.utils import load_stage_file
 
 
 class TestMove(TestDvc):
@@ -86,7 +87,7 @@ class TestMoveFileToDirectory(TestDvc):
         self.assertEqual(ret, 0)
         self.assertTrue(os.path.exists(foo_dvc_file))
 
-        new_foo_path = self.DATA_DIR+"/"+self.FOO
+        new_foo_path = os.path.join(self.DATA_DIR, self.FOO)
         new_foo_dvc_path = new_foo_path + Stage.STAGE_FILE_SUFFIX
         ret = main(["move", self.FOO, new_foo_path])
         self.assertEqual(ret, 0)
@@ -95,3 +96,74 @@ class TestMoveFileToDirectory(TestDvc):
         self.assertFalse(os.path.exists(foo_dvc_file))
         self.assertTrue(os.path.exists(new_foo_path))
         self.assertTrue(os.path.exists(new_foo_dvc_path))
+
+
+class TestMoveFileToDirectoryWithoutSpecifiedTargetName(TestDvc):
+    def test(self):
+        foo_stage_file_path = self.FOO + Stage.STAGE_FILE_SUFFIX
+        ret = main(['add', self.FOO])
+        self.assertEqual(ret, 0)
+        self.assertTrue(os.path.exists(foo_stage_file_path))
+
+        target_foo_path = os.path.join(self.DATA_DIR, self.FOO)
+        target_foo_stage_file_path = target_foo_path + Stage.STAGE_FILE_SUFFIX
+
+        ret = main(['move', self.FOO, self.DATA_DIR])
+        self.assertEqual(ret, 0)
+
+        self.assertFalse(os.path.exists(self.FOO))
+        self.assertFalse(os.path.exists(foo_stage_file_path))
+
+        self.assertTrue(os.path.exists(target_foo_path))
+        self.assertTrue(os.path.exists(target_foo_stage_file_path))
+
+        new_stage = load_stage_file(target_foo_stage_file_path)
+        self.assertEqual(self.FOO, new_stage['outs'][0]['path'])
+
+
+class TestMoveDirectoryShouldNotOverwriteExisting(TestDvc):
+    def test(self):
+        new_dir_name = 'data_dir2'
+        os.mkdir(new_dir_name)
+        ret = main(['add', self.DATA_DIR])
+        self.assertEqual(ret, 0)
+
+        ret = main(['move', self.DATA_DIR, new_dir_name])
+        self.assertEqual(ret, 0)
+
+        self.assertFalse(os.path.exists(self.DATA_DIR))
+        self.assertFalse(
+            os.path.exists(self.DATA_DIR + Stage.STAGE_FILE_SUFFIX))
+
+        self.assertTrue(os.path.exists(new_dir_name))
+        self.assertTrue(os.path.isfile(new_dir_name + Stage.STAGE_FILE_SUFFIX))
+
+        self.assertEqual(os.listdir(new_dir_name),
+                         [self.DATA_DIR])
+
+
+class TestMoveFileBetweenDirectories(TestDvc):
+    def test(self):
+        data_stage_file = self.DATA + Stage.STAGE_FILE_SUFFIX
+        ret = main(['add', self.DATA])
+        self.assertEqual(ret, 0)
+        self.assertTrue(os.path.exists(data_stage_file))
+
+        new_data_dir = 'data_dir2'
+        os.makedirs(new_data_dir)
+
+        ret = main(['move', self.DATA, new_data_dir])
+        self.assertEqual(ret, 0)
+
+        new_data_path = os.path.join(new_data_dir, os.path.basename(self.DATA))
+        new_data_stage_file = new_data_path + Stage.STAGE_FILE_SUFFIX
+
+        self.assertFalse(os.path.exists(self.DATA))
+        self.assertFalse(os.path.exists(data_stage_file))
+
+        self.assertTrue(os.path.exists(new_data_path))
+        self.assertTrue(os.path.exists(new_data_stage_file))
+
+        new_stage_file = load_stage_file(new_data_stage_file)
+        self.assertEqual(os.path.basename(self.DATA),
+                         new_stage_file['outs'][0]['path'])
diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py
index 0867f7924..cbb6bf558 100644
--- a/tests/utils/__init__.py
+++ b/tests/utils/__init__.py
@@ -1,3 +1,4 @@
+import yaml
 from mock import MagicMock
 
 
@@ -10,3 +11,8 @@ def spy(method_to_decorate):
 
     wrapper.mock = mock
     return wrapper
+
+
+def load_stage_file(path):
+    with open(path, 'r') as fobj:
+        return yaml.safe_load(fobj)

pip install -e .[all]
parse_log_pytest
requirements.txt
pytest>=3.3.1 mock>=2.0.0 coverage>=4.5.1 pytest
pip install --upgrade pip setuptools wheel
3.9
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
altgraph==0.17.4
appdirs==1.4.4
asciimatics==1.15.0
azure-common==1.1.28
azure-nspkg==3.0.2
azure-storage-blob==1.3.0
azure-storage-common==1.3.0
azure-storage-nspkg==3.1.0
bcrypt==4.3.0
boto3==1.7.4
botocore==1.10.84
cachetools==5.5.2
certifi==2025.1.31
cffi==1.17.1
charset-normalizer==3.4.1
colorama==0.4.6
configobj==5.0.9
configparser==7.2.0
coverage==7.8.0
cryptography==44.0.2
decorator==5.2.1
distro==1.9.0
docutils==0.21.2
-e git+https://github.com/iterative/dvc.git@f94717f4f1f660d8e97414ad5fc1b234a7f37bb1#egg=dvc
exceptiongroup==1.2.2
future==1.0.0
gitdb==4.0.12
GitPython==3.1.44
google-api-core==1.34.1
google-auth==2.38.0
google-cloud-core==0.28.1
google-cloud-storage==1.13.0
google-crc32c==1.7.1
google-resumable-media==2.7.2
googleapis-common-protos==1.69.2
grandalf==0.6
idna==3.10
iniconfig==2.1.0
jmespath==0.10.0
jsonpath-rw==1.4.0
macholib==1.16.3
mock==5.2.0
nanotime==0.5.2
networkx==3.2.1
packaging==24.2
paramiko==3.5.1
pefile==2024.8.26
pillow==11.1.0
pluggy==1.5.0
ply==3.11
protobuf==3.20.3
pyasn1==0.6.1
pyasn1_modules==0.4.2
pycparser==2.22
pydot==3.0.4
pyfiglet==1.0.2
PyInstaller==3.3.1
PyNaCl==1.5.0
pyparsing==3.2.3
pytest==8.3.5
python-dateutil==2.9.0.post0
PyYAML==6.0.2
requests==2.32.3
rsa==4.9
s3transfer==0.1.13
schema==0.7.7
six==1.17.0
smmap==5.0.2
tomli==2.2.1
urllib3==2.3.0
wcwidth==0.2.13
zc.lockfile==3.0.post1

name: dvc
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - altgraph==0.17.4
      - appdirs==1.4.4
      - asciimatics==1.15.0
      - azure-common==1.1.28
      - azure-nspkg==3.0.2
      - azure-storage-blob==1.3.0
      - azure-storage-common==1.3.0
      - azure-storage-nspkg==3.1.0
      - bcrypt==4.3.0
      - boto3==1.7.4
      - botocore==1.10.84
      - cachetools==5.5.2
      - certifi==2025.1.31
      - cffi==1.17.1
      - charset-normalizer==3.4.1
      - colorama==0.4.6
      - configobj==5.0.9
      - configparser==7.2.0
      - coverage==7.8.0
      - cryptography==44.0.2
      - decorator==5.2.1
      - distro==1.9.0
      - docutils==0.21.2
      - exceptiongroup==1.2.2
      - future==1.0.0
      - gitdb==4.0.12
      - gitpython==3.1.44
      - google-api-core==1.34.1
      - google-auth==2.38.0
      - google-cloud-core==0.28.1
      - google-cloud-storage==1.13.0
      - google-crc32c==1.7.1
      - google-resumable-media==2.7.2
      - googleapis-common-protos==1.69.2
      - grandalf==0.6
      - idna==3.10
      - iniconfig==2.1.0
      - jmespath==0.10.0
      - jsonpath-rw==1.4.0
      - macholib==1.16.3
      - mock==5.2.0
      - nanotime==0.5.2
      - networkx==3.2.1
      - packaging==24.2
      - paramiko==3.5.1
      - pefile==2024.8.26
      - pillow==11.1.0
      - pip==25.0.1
      - pluggy==1.5.0
      - ply==3.11
      - protobuf==3.20.3
      - pyasn1==0.6.1
      - pyasn1-modules==0.4.2
      - pycparser==2.22
      - pydot==3.0.4
      - pyfiglet==1.0.2
      - pyinstaller==3.3.1
      - pynacl==1.5.0
      - pyparsing==3.2.3
      - pytest==8.3.5
      - python-dateutil==2.9.0.post0
      - pyyaml==6.0.2
      - requests==2.32.3
      - rsa==4.9
      - s3transfer==0.1.13
      - schema==0.7.7
      - setuptools==78.1.0
      - six==1.17.0
      - smmap==5.0.2
      - tomli==2.2.1
      - urllib3==2.3.0
      - wcwidth==0.2.13
      - zc-lockfile==3.0.post1
prefix: /opt/conda/envs/dvc

tests/test_move.py::TestMoveFileToDirectoryWithoutSpecifiedTargetName::test tests/test_move.py::TestMoveFileBetweenDirectories::test
tests/test_move.py::TestMove::test tests/test_move.py::TestMoveNonExistentFile::test tests/test_move.py::TestMoveDirectory::test tests/test_move.py::TestCmdMove::test tests/test_move.py::TestMoveNotDataSource::test tests/test_move.py::TestMoveFileWithExtension::test tests/test_move.py::TestMoveFileToDirectory::test tests/test_move.py::TestMoveDirectoryShouldNotOverwriteExisting::test
dvc/project.py
dvc/project.py