Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Done move like unix mv

Oct
356
2
hello -- is there a combination of move switches that will make move work (somewhat) like unix mv?

I simply want to move directories on the same drive to be a sub-directory. so if I have the directories

foo
bar

that the same level

then

mv foo bar

would result in

bar\foo

in this case just the directories move

can this be done with move?
 
This is on the wishlist. Go vote for it to possibly make it a hotter topic.
 
From: fpefpe
| hello -- is there a combination of move switches that will make move
| work (somewhat) like unix mv?
|
| I simply want to move directories on the same drive to be a
| sub-directory. so if I have the directories
|
| foo
| bar
|
| that the same level
|
| then
|
| mv foo bar
|
| would result in
|
| bar\foo
|
| in this case just the directories move
|
| can this be done with move?

MOVE is different from "mv". However, I would try this alias:

alias mv=`*ren %1 %2\%1`
--
HTH, Steve
 
Is this similar to the norton commanders old Graft command? dit's easy to do an alias for Prune but not sure about graft would be...
----- Original Message -----
From: fpefpe
To: [email protected]
Sent: Thursday, September 01, 2011 12:45 PM
Subject: [Suggestions-t-3135] move like unix mv


hello -- is there a combination of move switches that will make move work (somewhat) like unix mv?

I simply want to move directories on the same drive to be a sub-directory. so if I have the directories

foo
bar

that the same level

then

mv foo bar

would result in

bar\foo

in this case just the directories move

can this be done with move?
 
hello -- is there a combination of move switches that will make move work (somewhat) like unix mv?

I simply want to move directories on the same drive to be a sub-directory. so if I have the directories

foo
bar

that the same level

then

mv foo bar

would result in

bar\foo

in this case just the directories move

can this be done with move?

I'm no Unix guru -- but isn't mv more like REN than MOVE?

Code:
ren /s foo bar\*
 
I'm a little surprised that it was so easy. I expected this to fail.

There was v:\1, containing file.txt, and v:\2 which was empty. I issued

Code:
v:\> move 1 2
V:\1 -> V:\2\1

The result was as the OP desired, no more v:\1, and now, v:\2\1 containing file.txt.

Is that reliable?

After that I did

Code:
move 2\1 1

v:\1 was recreated with file.txt in it. v:\2\1 was emptied but not removed.

I never liked MOVE. It has always been difficult to figure out how to "move named thing to named place" (which is unambiguous, isn't it?). I haven't even tried in years, always use Explorer to move things.

hello -- is there a combination of move switches that will make move work (somewhat) like unix mv?

I simply want to move directories on the same drive to be a sub-directory. so if I have the directories

foo
bar

that the same level

then

mv foo bar

would result in

bar\foo

in this case just the directories move

can this be done with move?
 
alias

Well it seams that the solution is:

Code:
alias CopyDir=COPY /L /S /E /X /Y /H /Z
alias MoveDir=RENAME /S

While this will do what the OP wish for this solution is pretty difficult to work out.

  • CopyDir needs a whooping 7 option. Unix has an "--archive" options which combines all option needed to make a 1 to 1 copy.
  • MoveDir needs to use RENAME which is not very intuitive.

So I am still on favour of some convenience commands or options to make these important functions easier accessible. This could be two new commands or an addition option like the "--archive" from unix (added to both MOVE and RENAME so it is easier to discover them).

PS: Would RENAME /S work across a file-systems? Because unix mv does by performing a copy / delete in these cases.
 
alias

From: krischik
| Code:
| alias CopyDir=COPY /L /S /E /X /Y /H /Z
| alias MoveDir=RENAME /S
|
| While this will do what the OP wish for this solution is pretty difficult to work out.
|
| CopyDir needs a whooping 7 option. Unix has an "--archive" options
| which combines all option needed to make a 1 to 1 copy.
| MoveDir needs to use RENAME which is not very intuitive.
|
| So I am still on favour of some convenience commands or options to
| make these important functions easier accessible. This could be two
| new commands or an addition option like the "--archive" from unix
| (added to both MOVE and RENAME so it is easier to discover them).

Actually, it is generally possible to combine options without a separate option character for each ( for your COPYDIR: /LEXYHZS), but it is deprecated for good reason. For example, the /S option has been enhanced a few versions age with suboptions (controlling how deep recursion depth starts or ends). If the character describing a future suboption is already a valid option, the parser would not be able to determine what you wanted. Separating each option makes it unambiguous even if there is an enhancement in the future.

Furthermore, in POSIX syntax, would you type "cp --archive" each time, or would you create an alias (eg., alias arch=cp --archive) anyway? I would - just as I created tens of aliases for various options of the DIR and PDIR commands - naming them very systematically so a particular option (or group of options) always be represented identically. For example in PDIR variants are suffixed "s" if they are to report descend into subdirectories but not into junctions (my most common usage), and with "sj" if junctions are to be searched, too.

| PS: Would RENAME /S work across a file-systems? Because unix mv does
| by performing a copy / delete in these cases.

No. As described in the HELP topic REN/RENAME it cannot cross file system (volume) boundaries. OTOH MOVE is described as performing REN if source and target are on the same volume, otherwise it performs COPY / DEL, just as POSIX' mv does.

Beware of REN /S - it does not behave in the same manner as /S in other commands. Read the HELP topic CAREFULLY.

To move a directory AND all its entries, including both files and subdirectories, you can use either REN (if remaining on the same volume) or MOVE. You do not need the /S option in either case.
--
HTH, Steve
 
Re: alias

Well it seams that the solution is:

Code:
alias CopyDir=COPY /L /S /E /X /Y /H /Z
alias MoveDir=RENAME /S

While this will do what the OP wish for this solution is pretty difficult to work out.

It doesn't do what the OP asked for:

HTML:
C:\Junk>mkdir foo

C:\Junk>mkdir bar

C:\Junk>COPY /L /S /E /X /Y /H /Z foo bar
     0 files copied

C:\Junk>ffind /s *
C:\Junk\bar
C:\Junk\foo

      2 files

C:\Junk>bar\

C:\Junk\bar>dir

 Volume in drive C is OS             Serial number is 1ce5:1203
 Directory of  C:\Junk\bar\*

 9/28/2011  12:42p        <DIR>    .
 9/28/2011  12:42p        <DIR>    ..
                 0 bytes in 0 files and 2 dirs
   157,316,251,648 bytes free

It also doesn't do the following:

HTML:
C:\Junk>mkdir D1

C:\Junk>mkdir D2

C:\Junk>mkdir S

C:\Junk>COPY /L /S /E /X /Y /H /Z d* S\
TCC: Infinite COPY or MOVE loop "C:\Junk\d*"

C:\Junk>dir

 Volume in drive C is OS             Serial number is 1ce5:1203
 Directory of  C:\Junk\*

 9/28/2011  12:36p        <DIR>    .
 9/28/2011  12:36p        <DIR>    ..
 9/28/2011  12:35p        <DIR>    D1
 9/28/2011  12:35p        <DIR>    D2
 9/28/2011  12:36p        <DIR>    S
                 0 bytes in 0 files and 5 dirs
   157,316,825,088 bytes free

Also, it doesn't solve the problem discussed in http://jpsoft.com/forums/showthread.php?t=2442 .
 
From: krischik
Furthermore, in POSIX syntax, would you type "cp --archive" each time, or would you create an alias

True. But then there is cp -a as a short form as well. And I do have an alias as well.

To move a directory AND all its entries, including both files and subdirectories, you can use either REN (if remaining on the same volume) or MOVE. You do not need the /S option in either case.

I had situations where MOVE had flattened the directory structure or where MOVE would move one file and directory at a time.

So MOVE is more difficult to use then RENAME

It doesn't do what the OP asked for:

True, there are a few corner cases where it does not work. And generality you have to spell out the destination:

Code:
COPY /L /S /E /X /Y /H /Z foo bar/for

RENAME /S foo foo/bar

which too is a bit of a pain. So, I am with OP asking for improved directory management. And if we are it, why not DelDir as well?

I know: Because it clutters the up the command name space. I wonder if Rex Conn ever need to move to 2 word commands.
 

Similar threads

Back
Top