[SOLVED] Rename Folder

This forum is dedicated to basic help and support :

Ask here your questions about basic installation and usage of Mageia. For example you may post here all your questions about getting Mageia isos and installing it, configuring your printer, using your word processor etc.

Try to ask your questions in the right sub-forum with as much details as you can gather. the more precise the question will be, the more likely you are to get a useful answer

[SOLVED] Rename Folder

Postby laskachien » Jun 1st, '13, 18:27

Hello in bash
I d tried -v rename folder1 folder2 answer -v not found try cnf -v...(often some options give me the same answer!)
can I also try -v mv folder1 folder2? and folder1 is removed?
Must I be out of folder1?Thanks
Last edited by laskachien on Jun 4th, '13, 10:42, edited 3 times in total.
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: Rename Folder

Postby doktor5000 » Jun 1st, '13, 19:35

Any reason why you want to do this in a terminal, whereas you complained about linux being only for experts? Why not use a graphical file manager like dolphin or nautilus?

Apart from that, rename only works on files, not on folders. Don't know why you put -v in front, that will not work. And mv works to rename folders, if you use it correctly.
But you need to provide more information, e.g. in which folder you were, and the command you used and the output you got.

Small example how to provide this information:

I'm in my /home folder:

Code: Select all
[doktor5000@Mageia3 ~]$ pwd
/home/doktor5000


I want to rename a folder "testfolder" to "newfoldername", this is what it looks before:
Code: Select all
[doktor5000@Mageia3 ~]$ ls -ald testfolder
drwxrwxr-x 2 doktor5000 doktor5000 4096 Jun  1 19:32 testfolder/

Renaming it:
Code: Select all
[doktor5000@Mageia3 ~]$ mv testfolder/ newfoldername

This is what it looks afterwards:
Code: Select all
[doktor5000@Mageia3 ~]$ ls -ald newfoldername/
drwxrwxr-x 2 doktor5000 doktor5000 4096 Jun  1 19:32 newfoldername/
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18067
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Rename Folder

Postby laskachien » Jun 2nd, '13, 10:51

Thanks
I want to use bash to learn it,as I learned 20years ago C and 40 Dos and Basic.But as I m 84old I make more mistakes now!
No notice had tell me that rename work only on files 1st error.I wanted to change ToTo in titi I was in ToTo folder 2d error. -v for verbose.
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: [SOLVED] Rename Folder

Postby doktor5000 » Jun 2nd, '13, 11:08

You always need to put options like -v behind the command, not in front, otherwise shell thinks this is a separate command.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18067
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: [SOLVED] Rename Folder

Postby laskachien » Jun 2nd, '13, 14:19

http://ss64.com is an index of bash cdes it s interesting!
Thanks now I has learned more.
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: Rename Folder

Postby laskachien » Jun 3rd, '13, 11:27

Sorry I ts me again I tried your in /home [carl...]$ mv oldf / newf
answer newf not found So I try
$ mkdir newf ok then
$ mv oldf / newf
The result is that newf contains oldf who contains 3files
I want to have newf containing the 3 files,and oldf removed!
Another Q about really I must change a long dir name in french "Téléchargements" for dwnld.Do this change be reconized by the download manager?
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: Rename Folder

Postby Mayavimmer » Jun 3rd, '13, 14:04

laskachien wrote:Sorry I ts me again I tried your in /home [carl...]$ mv oldf / newf
answer newf not found So I try
$ mkdir newf ok then
$ mv oldf / newf
The result is that newf contains oldf who contains 3files
I want to have newf containing the 3 files,and oldf removed!

Beware of different behaviors depending on whether the second folder exists or not!
First let's create and work in a new empty folder (directory):
user ~ $ mkdir zzz
user ~ $ cd zzz

Now let's create a small directory containing two files:
user zzz $ mkdir dir1
user zzz $ touch dir1/file1
user zzz $ touch dir1/file2

Let's see what we have:
user zzz $ find *
dir1
dir1/file2
dir1/file1

Now rename dir1 to dir2, where there is NO PREEXISTING dir2:
user zzz $ mv dir1 dir2
user zzz $ find *
dir2
dir2/file2
dir2/file1

Try again, but with a preexisting dir3:
user zzz $ mkdir dir3
user zzz $ mv dir2 dir3
user zzz $ find *
dir3
dir3/dir2
dir3/dir2/file2
dir3/dir2/file1

DIFFERENT BEHAVIOR! Now dir2 is INSIDE dir3!

Finally clean up temporary files:
user zzz $ cd ..
user ~ $ rm -rf zzz
Mayavimmer
 
Posts: 27
Joined: Nov 30th, '12, 10:17

Re: Rename Folder

Postby laskachien » Jun 3rd, '13, 15:47

Oh what an interesting answer,who explain the subtle of the mv cde!!!No book give such detailed explanations.Thanks for.But why bash do not have a simple "renamedir"for this simple task!
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: Rename Folder

Postby doktor5000 » Jun 3rd, '13, 19:20

laskachien wrote:Sorry I ts me again I tried your in /home [carl...]$ mv oldf / newf
answer newf not found


Did you copy&paste that command? As there's a blank between oldf and the following /
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18067
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Rename Folder

Postby laskachien » Jun 3rd, '13, 19:24

I try your thread OK it s well,and now I think I understant why before it do not work
doktor5000@Mageia3 ~]$ mv testfolder/ newfoldername
in this line there is a / and I think because it I get the answer newf....not found.And therefor I made an error with mkdir
mv testfolder newf... must go
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: Rename Folder

Postby doktor5000 » Jun 3rd, '13, 19:44

BTW: You may want to have a look at http://steve-parker.org/sh/sh.shtml or, recommended elsewhere already: http://nixsrv.com/llthw
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18067
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Rename Folder

Postby laskachien » Jun 4th, '13, 10:41

Yes very interesting just what I need to learn more Thanks
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39

Re: SOLVED Rename Folder

Postby srtxg » Jun 5th, '13, 16:29

the "mv" comand moves files (or directories).
If you have only two arguments, eg "mv A B", then "A" will be moved to "B":
1. if B doesn't exists then A will be renamed to B
2. if B exists and is a directory then A will be moved *into* B
3. if B is a file and A is file too, then A will *overwrite* B (that is, old B will be deleted, and A renamed to B)
4. if A is a dir and B a file then error

now, if there are three or more parameters, then the last one *MUST* exist and be a directory
the command is them: move everything into that last directory.

You typed: "mv oldf / newf"
There are three parameter there: "oldf", "/" and "newf". So newf *must* be a directory and exist.
Note that "/" is the root directory, that is your WHOLE system; trying to move it won't work; maybe it can lead to a partial move and your system being unworking because of very important thing like ld.so or bash or /dev not being at the expected place anymore.
Not what you wanted to do anyway. I think you wanted to type: "mv oldf newf"
srtxg
 
Posts: 21
Joined: Jun 5th, '13, 11:13

Re: SOLVED Rename Folder

Postby laskachien » Jun 5th, '13, 21:37

I did not suspect ,that for a simple act to ren a dir it s so subtle.But now I m an expert with mv!!!I try http://nixsrv.com/llthw given by Dr5000,it is very interesting,but you must have a good logic as the exercises has been edited for DEBIAN,so some differences appears.In digging and digging more and more,I face now more questions than solutions!!!
laskachien
 
Posts: 109
Joined: Apr 23rd, '13, 10:39


Return to Basic support

Who is online

Users browsing this forum: No registered users and 1 guest