Page 1 of 1

Move command not creating target directories

Posted: Fri Sep 15, 2023 4:01 am
by daveyw
Hi,

I don't use Move very much, but am taking a look at it for a script I'm building. According to the docs, "If you name a destination directory that does not exist, MOVE will create a directory with that name." Either I'm doing it worng, or its not functioning as intended.

Code: Select all

move temp:foo.txt to misc:bar
I would expect this to create a new folder on misc: called "bar" and move foo.txt into it. However, it actually moves foo.txt to misc: and renames it to bar.

How do I move a file, create a target directory that doesn't exist, and keep the original name?

Re: Move command not creating target directories

Posted: Fri Sep 15, 2023 11:48 am
by nbache
I think it will only do that if you move a directory (and any contents), not a file. The examples in the doc seem (at a brief glance) to support this theory.

I tried if adding a slash to the destination (to make it explicit that it is/should be a directory) would help, but that just gives an error (rename across devices or something like that).

I'm not sure it's really the task of move to be able to transparently create such a directory which has been implicitly specified.

It's probably more reasonable (also to make the script more understandable) to create the dir with Makedir first. Also remember, if you need it, that Makedir can create several layers of directories in one go with the ALL switch.

Best regards,

Niels

Re: Move command not creating target directories

Posted: Sun Sep 17, 2023 8:08 pm
by OldFart
@daveyw

Have you tried this version:

Code: Select all

move temp:foo.txt to misc:bar/foo.txt
?

OldFart

Re: Move command not creating target directories

Posted: Mon Sep 18, 2023 1:38 am
by daveyw
If Misc:bar folder doesn't exist, this results in an error:

"Cannot open "foo.txt" for output - MOVE: object not found"