![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Sorting files by month How would you write a script to sort files by month. For example a file named January 1, February 13, March 27, etc. I have a folder that has files in it with a daily log for each day. Each file is called Aug. 1, 09; Aug. 2, 09, etc., Sept. 1, Oct. 1, 09. How would I sort them by month, day, year. Please be detail with answer since I am new to scripting. Any where can I get more info. -- Ed |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Sorting files by month "Ed" <Ed@newsgroup> wrote in message news:0865DB3F-4E20-46B1-9495-1DAEE383CDF3@newsgroup Quote: > How would you write a script to sort files by month. For example a file > named > January 1, February 13, March 27, etc. I have a folder that has files in > it > with a daily log for each day. Each file is called Aug. 1, 09; Aug. 2, 09, > etc., Sept. 1, Oct. 1, 09. How would I sort them by month, day, year. > Please > be detail with answer since I am new to scripting. Any where can I get > more > info. you want them sorted in this order when you look at them (the names of the files) in a folder explorer window. Another person might think you want them sorted this way when their names are listed in an Excel table or in a web page or printed on paper. Someone else might think you want the files physically moved around on the hard drive to be placed in this order. You might mean something entirely different. -Paul Randall |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Sorting files by month "Ed" <Ed@newsgroup> wrote in message news:0865DB3F-4E20-46B1-9495-1DAEE383CDF3@newsgroup Quote: > How would you write a script to sort files by month. For example a file > named > January 1, February 13, March 27, etc. I have a folder that has files in > it > with a daily log for each day. Each file is called Aug. 1, 09; Aug. 2, 09, > etc., Sept. 1, Oct. 1, 09. How would I sort them by month, day, year. > Please > be detail with answer since I am new to scripting. Any where can I get > more > info. > -- > Ed file script56.chm from http://www.microsoft.com/downloads/d...displaylang=en so that you can write at least some of the code yourself rather than holding out an empty hand and asking someone to do all the work for you. You might also view the posts in this newsgroup - there are lots of scripting examples here. |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Sorting files by month In microsoft.public.scripting.vbscript message <0865DB3F-4E20-46B1-9495- 1DAEE383CDF3@newsgroup>, Sat, 31 Oct 2009 11:10:01, Ed <Ed@newsgroup> posted: Quote: >How would you write a script to sort files by month. For example a file named >January 1, February 13, March 27, etc. I have a folder that has files in it >with a daily log for each day. Each file is called Aug. 1, 09; Aug. 2, 09, >etc., Sept. 1, Oct. 1, 09. How would I sort them by month, day, year. Please >be detail with answer since I am new to scripting. Any where can I get more >info. Such programming tasks are much easier if dates (and times) are all given in ISO 8601 form ; it is at present 2009-11-01 17:11 GMT. -- (c) John Stockton, nr London, UK. ?@merlyn.demon.co.uk Turnpike v6.05. Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc. |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Sorting files by month James Watkins provided a link to the scripting help. Once you have that, see the FileSystemObject (FSO). With FSO you can access a folder and its files as objects. Each file has a Name property. Then there's a Split function that will return an array from a string, based on delimiters. Say you have the file Oct. 1, 09 and you return its name. Then you could do the following to simplify the operation: sName = Replace(sName, ",", "") ' remove comma sName = Replace(sName, ".", "") ' remove period. AName = Split(sName, " ") That will split sName into an array by splitting it at each space. The result will be: AName(0) = "Oct" AName(1) = "1" AName(2) = "09" Once you have that array it's easy to sort the items: sMonth = AName(0) Select Case sMonth Case "Jan" Case "Feb" ' ...etc.... End Select That should be enough info., along with the help file, to work out the details of the sorting. It's hard to make it more clear without just writing your whole script for you. Quote: > How would you write a script to sort files by month. For example a file Quote: > January 1, February 13, March 27, etc. I have a folder that has files in Quote: > with a daily log for each day. Each file is called Aug. 1, 09; Aug. 2, 09, > etc., Sept. 1, Oct. 1, 09. How would I sort them by month, day, year. Quote: > be detail with answer since I am new to scripting. Any where can I get Quote: > info. > -- > Ed |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Sorting files by month Ed wrote: Quote: > How would you write a script to sort files by month. For example a > file named January 1, February 13, March 27, etc. I have a folder > that has files in it with a daily log for each day. Each file is > called Aug. 1, 09; Aug. 2, 09, etc., Sept. 1, Oct. 1, 09. How would I > sort them by month, day, year. Please be detail with answer since I > am new to scripting. Any where can I get more info. mentioned, I would just click on "Modified" at the top of the date column in Explorer to sort them by date. No scripting needed. -- Todd Vargo (Post questions to group only. Remove "z" to email personal messages) |
My System Specs![]() |
| | #7 (permalink) |
| | Re: Sorting files by month If you rename the files using YYYYMMDD format the files will sort themselves. |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Sorting files | VB Script | |||
| zip files created within same month | PowerShell | |||
| Sorting files in a folder | VB Script | |||
| Autmatically Sorting Files | Vista General | |||
| WMP - sorting files | Vista music pictures video | |||