AutoHotkey Community

It is currently May 26th, 2012, 9:19 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: autosort
PostPosted: November 14th, 2007, 7:50 pm 
Hi,

I am trying to write a program to sort my jpgs by date created. I have recieved alot of help and I want to say thank you. I almost have what I am trying to achieve.

What I am wanting is for it to be recursive. So that if I say sort the "My Pictures" directory that it will sort that folder and all sub folders within subfolders, within subfolder, inside of "my pictures" I have not been successful. I think I am trying to make it to hard. I have been trying to read all folders within a directory, put them into an array and then run the program on each of them. This may be indeed how you do it, but I can not get it to work. Also, it seems that there should be an easier way. Here is my working base code



Code:
Gui,Font,Bold
Gui,Font,Underline
Gui,add,Text,   w400 x1   y10  Center,AutoSort
Gui,Font,Norm
Gui,Font,Bold
Gui,Add,Text,   w400 x1   y60  Center,This program will sort the file extension that you input
Gui,Add,Text,   w400 x1   y75  Center,into the text field below into individual folders labeled by
Gui,Add,Text,   w400 x1   y90  Center,the date the file was created.
Gui,add,Text,   w200 x90   y110  Center, Enter three digit file extension:
Gui,add,edit,   w28  x280 y108  vMyEdit,
Gui,add,button, w400 x1   y130 gSelect, select Folder to sort
Gui,show, w401
Return

MoveDateCreated:
Gui,Submit
formattime, begin,,MMMM dd yyyy
MoveFiles = 0
;msgbox,%MyEdit%
Loop,  %outputvar%\*.%MyEdit%,0,1
{
  FormatTime, ALFTC, %A_LoopFileTimeCreated%, MMMM dd yyyy
  NewFolder := A_LoopFileDir "\" ALFTC
  IfNotExist, %NewFolder%
  FileCreateDir, %NewFolder%
; save the moving for later
  MoveFiles++
  MoveFileFrom%MoveFiles% := A_LoopFileLongPath
  MoveFileto%MoveFiles%   := NewFolder
}

Loop %MoveFiles%
{
  FileMove,% MoveFileFrom%A_Index%, % MoveFileTo%A_Index%
}
Return


Select:
FileSelectFolder, OutputVar, , 3
gosub, MoveDateCreated
Return


any help would be appreciated


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 14th, 2007, 8:25 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
i dont understand what youre doing. why cant you righ click and go "sort by date created" in explorer? what exactly are you doing?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2007, 1:27 am 
I have 5gbs of unsorted pictures, in random folders in the my pictures directory. I am moving the pictures into folders by the date they were created. So that they will be organized by the date they were created in pretty well named folders. I have that part working what I want now is to make the program recursive.

Say I have 20 folders and some of those folders have folders inside of them. I want this program to sort all the folders in a directory and process any subfolders within those folders.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2007, 5:13 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Your script already does that...

Perhaps you want the "MMMM dd yyyy" folders to all be created in the one parent folder? If so, I suppose you should change
Code:
  NewFolder := A_LoopFileDir "\" ALFTC
to
Code:
  NewFolder := outputvar "\" ALFTC


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2007, 3:17 pm 
when I run my script and I point it at the "My Pictures" directory it only sorts files that are in the "My Pictures" directory.

The problem is that within the "My Pictures" directory I have multiple other folders which this script ignores. I want the script to sort the "My Pictures" directory and all the folders within "My Pictures" I just cant figure out how to do it.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 15th, 2007, 6:31 pm 
Offline
User avatar

Joined: August 30th, 2005, 8:43 pm
Posts: 8666
Location: Salem, MA
you already have it set to recurse. if it's not working, you need to edit your Loop line

_________________
Image
(Common Answers) - New Tutorials Forum - Humongous FAQ


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2007, 12:34 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
begin wrote:
when I run my script and I point it at the "My Pictures" directory it only sorts files that are in the "My Pictures" directory.
It works for me, but it puts the "MMMM dd yyyy" folders in the sub-folders that contained the pictures, not directly the "My Pictures" directory...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2007, 2:31 am 
ok lexikos I see what you are saying, how do I fix it though? Or is this just the way it is?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2007, 2:37 am 
Offline

Joined: November 3rd, 2007, 12:41 am
Posts: 188
If I understand your question properly I would change this line:

Code:
  NewFolder := A_LoopFileDir "\" ALFTC


Replace A_LoopFileDir with a variable that contains the name of the directory that you want all your folders created in.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 16th, 2007, 3:47 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
Lexikos wrote:
Perhaps you want the "MMMM dd yyyy" folders to all be created in the one parent folder? If so, I suppose you should change
Code:
  NewFolder := A_LoopFileDir "" ALFTC
to
Code:
  NewFolder := outputvar "" ALFTC
:roll:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 17th, 2007, 5:00 pm 
thank you all for your assistance. :)


Report this post
Top
  
Reply with quote  
PostPosted: July 28th, 2009, 6:41 pm 
Offline

Joined: July 28th, 2009, 6:14 pm
Posts: 9
There's a utility that can perform some of the functions described here called DirUtils. It's pretty handy. Not ahk based. http://web.archive.org/web/20080215000029/http://www.niftyprograms.com/files/dirutilsv1setup.exe

found at http://web.archive.org/web/20080215000029/http://www.niftyprograms.com/dirutils.htm
referred by lifehacker http://lifehacker.com/378186/save-time-organizing-files-with-dir-utils-right+click-tools


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 28th, 2009, 7:55 pm 
Online

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
not sure if this is what you mean but...
set up the view of the folder the way you want them all to look. including the sort method then fallow this image:
Image
(url) http://a.imagehost.org/0246/Clipboard02.jpg

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, wolverineks and 65 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group