Update: I see that this post has gotten a down vote for no apparent reason from the voter (no reply to my post).
That is unfortunate.
If that happened because my tone may offend the OP, it was not my intent at all to offend the OP.
I see the problem of not understanding the idea of "text of filename"->(pointer) to data often with Windows students.
If there is a way to explain it better than I did, then great! Please post!

---original post continues---

Deleted perhaps inflammatory statement.

Your question demonstrates a fundamental lack of understanding of how a file system works.A file does not "exist in a directory" - NO! - that is not what happens!

As a simplification, lets say that a file is just a "block of contiguous bits/bytes on the disk". The disk is a huge block of contiguous bytes from say byte 0 to byte 2,000,000,000. A file may exist from byte 10356 to byte 22356 on the disk.

The directory entry for "c:\ksk\vista\sra.txt" would be a data structure with an association between that text name and a pointer to say byte 10356 as the "start" and this text name would also have a length of 22356-10356+1 bytes associated with it. There would be other properties associated with that text name - this is called a "directory entry" - like the telephone "white pages": name, address, etc.

So if we "rename" sra.txt to SRA_new.txt:
That means that this directory entry text name that associates "c:\ksk\vista\sra.txt" to byte 10356 on the disk changes to "c:\ksk\vista\SRA_new.txt". No data on the disk moves.

If we want to "move" the file to a different directory on the same physical disk drive/file system, no bits in the file are actually "moved"!! NO!! We just create a new entry: "C:\home\sra.txt" to point to byte 10356 and delete the entry for "c:\ksk\vista\sra.txt".
So "moving a file to a different directory on the same disk" is the same as "renaming it"!

Moving a file from one physical disk to another is different. We have to create a directory entry on the other disk, copy the bits from disk1 to disk2, delete the directory entry on disk1, etc.

I am sorry that I got long winded here. But there is NO difference in what happens to the bits on the disk between "changing the name associated with those bits" and "moving those bits to a different directory" - this is just changing the text name associated with the starting byte of the data.


In reply to Re: renaming a file and moving into another folder by Marshall
in thread renaming a file and moving into another folder by sravan008

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.