19

I have folders with these names:

  • Introduction
  • Theoretical Background
  • Methods
  • Results
  • Conclusion

and would like to keep this sequence.

Unfortunately, Windows 7 doesn't let me and orders the folders according to their names or alteration date.

How can I fix the sequence of folders in Windows 7 and 10 according to my requirements?

Is it maybe possible to set an additional folder attribute like "1" or "2" and let Windows sort according to this attribute?

  • 1
    You want to observe this sequence in what context? In Explorer? Something else? Directory order is ultimately a property of display, not of the filesystem (though one can leverage various properties at the filesystem layer to manifest various orderings) – Lightness Races in Orbit Sep 20 at 13:21
  • I would like to oberserve this sequence in the file explorer. – Daniel Sep 20 at 23:21
49

I generally do this by simply prefixing the folders with either letters or numbers, as though they were sections of a document:

1 - Introduction
2 - Theoretical Background
3 - Methods
4 - Results
5 - Conclusions

If there are more than ten "sections", I will use a two-digit zero-padded prefix, e.g., 01, 02, 03, etc.; I've never been quite so deranged as to insist that I need this for a group of over about 15 folders. (Even if I did, I could probably manage to script the rename.)

  • Alphabetic chapter ordinals also work well (A,B,C). – Christopher Hostage Sep 18 at 15:57
  • I think even Windows 7 is smart enough to sort 2 before 10. Zero-prefixing is not necessary in that case. – MSalters Sep 19 at 13:00
  • 3
    Upvoted. Although it tweaks the question a bit, this solution is stable across different file systems, works with backups, and is even portable to other operating systems. – Dubu Sep 19 at 13:01
  • 4
    @MSalters - Yes, Windows is smart enough to do so, but occasionally I've gotten anomalous results where it doesn't sort numerics as numerics, so I zero-pad just to prevent that. – Jeff Zeitlin Sep 19 at 13:45
  • 1
    As for why you may see this vary, numeric sorting of this type is a feature of Explorer - only in Windows XP and later - and is optional, enabled by default. Other applications presenting file lists may choose their own sorting methods. "Open/Save File" dialogs utilizing the shell sort the same way, though. – Corrodias Sep 19 at 18:57
20

You can make the folders a system folder with a desktop.ini file.

Create a new text file within the folder, and set the content

[.ShellClassInfo]
InfoTip=1
[ViewState]
Mode=
Vid=
FolderType=Generic

Where InfoTip=1 sets the "tag" as "1", so you can sort numerically

Then rename the file to desktop.ini.

Then set the folder as a system folder using command prompt

attrib +s "Introduction"

Then in the root folder:

View → Choose Details → add "Comments"

And sort by Comments, now the folders will be sorted according to the "InfoTip" field in the ini file as long as the folder is marked as a system folder.

  • Nice. Setting the read-only attribute on the folder also works. Quickest way to create desktop.ini & set the folder attributes is to assign a custom icon via the Properties dialog. Then edit the desktop.ini file it creates. – Keith Miller Sep 19 at 4:00
  • 2
    +1 because you taught me something, but it looks too much of a hassle. I prefer the solution suggested by @JeffZeitlin. – dr01 Sep 20 at 7:16
  • @dr01 it actually is not too much hassle, you can just copy and edit the ini file, and you can attrib * to all contents of a directory in one go, a dozen directories take about a minute – Richie Frame Sep 20 at 14:20
  • 1
    +1 because this answer doesn't alter paths. Answers based on renaming will break anything that expects (relies on) certain names/paths. If this happens, fixing may be a real hassle; and if you ever need to change the order then you may need to fix again. In these circumstances this answer may lead to less hassle in total. – Kamil Maciorowski Sep 21 at 9:50
  • This solution, while interesting and useful, assumes and requires that 'show hidden and system files and folders' be set, which may not be considered desirable. – Jeff Zeitlin Sep 25 at 11:10
20

Update per comments: doesn't have to be a minute apart, only creation order matters.

If you create them at least a minute apart in the order you want, you can then sort by Date Created. enter image description here

  • 2
    I like that. Nice workaround. – wrecclesham Sep 18 at 14:20
  • 8
    The drawbacks with this method (other than waiting a minute between creating each folder) are that Date created isn't shown by default, and it would be very difficult to insert an additional folder between two existing ones. I'd go with Jeff's suggestion of numbering the folders. If you need them without numbers, copy to new folders (in order, a minute apart) at the very end (renaming doesn't seem to change either the modified- or created- times). – TripeHound Sep 18 at 15:26
  • 2
    If you copy a folder structure, it will not preserve the creation date. – Boann Sep 19 at 2:51
  • 3
    "Minute apart" does not matter. Actual creation time in the for system is precise to the second regardless of what you see in explorer. – n0rd Sep 19 at 14:19
  • @n0rd: When I was testing for my response, it seemed like it mattered, even though I thought it shouldn't, knowing the nature of the value. But it seemed like it matttered at the time. I test now & indeed, as one would expect, the comparison uses the intermal precision, not display percision. – Keith Miller Sep 21 at 0:22
1

A variation on Jeff's answer (also interferes little with default Windows behavior and is quickly accomplished): add 4,3,2,1 and 0 spaces in front of the directory names:

    Introduction
   Theoretical Background
  Methods
 Results
Conclusions

A matter of taste ;-)

  • Explorer in Windows 8 deletes leading/trailing whitespace, and I'm pretty sure Windows 7 and 10 do to. – wjandrea Sep 20 at 20:50
  • 1
    @wjandrea Indeed (tested Win10). I never work from Explorer (always Total Commander) so I did not notice. – Jan Doggen Sep 20 at 21:43
0

One thing is a real (physical) order of files / directories, the other is their logical order (sorted by name, by extension, ...) shown in File Managers.

Use such a file manager (instead of Widnows Explorer) who is able to show files in their physical order (i.e. unsorted). For example Total Commander:

enter image description here

  • 10
    There is no guarantee that the physical order will be the order that the user wants. This also requires installing third-party software, which may or may not be an option for the querent. – Jeff Zeitlin Sep 18 at 16:40
  • That is file-system dependent, and won't work on NTFS for example, see e.g. this. – dxiv Sep 19 at 20:38
  • @dxiv, interesting. Thanks! – MarianD Sep 19 at 21:33
  • 1
    Some file managers, like Directory Opus, can do manual sorting and saves the order. – Tom A. Vibeto Sep 20 at 7:42
0

First of all, thank you so much for your responses to my question!

I presented them to my colleagues and now half of them are using Jeff's and the other half Richie's solution.

Jeff's solution is, as pointed out by @Dubu, stable across different file systems, works with backups and is portable to other operating systems. Moreover, the solution is fast and easy to accomblish for everyone.

Now, let's assume you are using LaTeX for writing your thesis, then you will use similiar lines of code to insert your sections:

\input{./03_Section_A/Section_A.tex}
\input{./04_Section_B/Section_B.tex}

Let's also assume that you make the decision to add a new section, which should come between two existing sections (here between 03 and 04). Which changes are needed to add the new section in the sequence of folders? Using Jeff's solution, you need to rename all existing folders and adjust all paths in your LaTeX file accordingly:

\input{./03_Section_A/Section_A.tex}
\input{./04_NewSection/NewSection.tex}
\input{./05_Section_B/Section_B.tex}

Here, Richie's solution comes in handy. In fact, you do not need numbers in front of folder names anymore. If you make the decision to add a new section, which should come between two existing sections, you just need to update the desktop.ini files. Any adjustments in the LaTeX file, besides inserting the new section, is not needed.

\input{./SectionName_A/Section_A.tex}
\input{./NewSection/NewSection.tex}
\input{./SectionName_B/Section_B.tex}

To sum up, it is a personal decision to use Jeff's or Richie's solution. Both of them are great.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.