Move command not creating target directories

A forum for general AmigaOS 4.x support questions that are not platform-specific
Post Reply
User avatar
daveyw
Posts: 252
Joined: Mon Sep 12, 2011 7:44 pm

Move command not creating target directories

Post 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?
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1717
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Move command not creating target directories

Post 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
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Move command not creating target directories

Post by OldFart »

@daveyw

Have you tried this version:

Code: Select all

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

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
daveyw
Posts: 252
Joined: Mon Sep 12, 2011 7:44 pm

Re: Move command not creating target directories

Post by daveyw »

If Misc:bar folder doesn't exist, this results in an error:

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