Jump to content


Photo

Sort Any Folder v1.21


  • Please log in to reply
21 replies to this topic

#1 aaronbewza

aaronbewza
  • Members
  • 466 posts

Posted 01 May 2011 - 10:33 AM

Sort Any Folder
version 1.2.1.0

System Requirements:
Windows XP, Vista, 7 and above (32 or 64-bit)

Download latest version:
Sort Any Folder.ahk (must compile EXE to use right-click context menu function)
Sort Any Folder.exe (recommended, works with right-click context menu)

Description:
Creates subfolders in selected folder and sorts files into them.
User is then given choices to move sorted documents, pictures and music
into User's regular Documents, Pictures and Music folders
(Uses My Documents, My Pictures and My Music folders in XP).

Subfolders created in User-selected folder (only if file extensions exist):

Unsorted AHK Scripts
Unsorted Documents
Unsorted EXE Files
Unsorted Music
Unsorted PDF Files
Unsorted Pictures
Unsorted Video
Unsorted Zip Files

Version History:
v1.0.0.0 - got the idea from here (thanks guys!): Sorting my downloaded files
v1.1.0.0 - improved range of file types that are recognized and sorted
v1.2.0.0 - implemented "Loop, Parse" to optimize looking for file extensions
v1.2.1.0 - added "Sort This Folder" context menu option (thanks newbie123)


#2 polyester

polyester
  • Guests

Posted 01 May 2011 - 12:35 PM

Now it would be great if files could be sorted into subfolders by their content & relevance, and then these subfolders could be labeled accordingly. :lol:

#3 sumon

sumon
  • Moderators
  • 1307 posts

Posted 01 May 2011 - 01:25 PM

Now it would be great if files could be sorted into subfolders by their content & relevance, and then these subfolders could be labeled accordingly. :lol:


Content and relevance as in what text is in the files, or what? Haha :D

#4 aaronbewza

aaronbewza
  • Members
  • 466 posts

Posted 01 May 2011 - 01:49 PM

That would be great, but I have no idea how to do that. I would really like to know how to use "IfExist" on multiple files in block brackets so a list of file extensions can be added to one single instance of "IfExist".
I'm not sure how it could be done, something like this maybe:
IfExist,
{
*.wav
*.mp3
*.mid
*.wma
}
FileCreateDir, Music
Something like that would search out the listed file extensions and only create the folder "Music" if one or more of the file extensions appear in the target folder. Anyone have a solution for that?

#5 x79animal

x79animal
  • Members
  • 1021 posts

Posted 01 May 2011 - 02:02 PM

use a parse loop, i would have made an example but not that sure on what you wanted to do

<!-- m -->http://www.autohotke...s/LoopParse.htm<!-- m -->

#6 aaronbewza

aaronbewza
  • Members
  • 466 posts

Posted 01 May 2011 - 02:11 PM

I'd like to use only one instance of "IfExist" to look for more than one file extension name, for example... if there is one or more Mp3 files, it will create the "Music" subfolder. If there is one or more WAV files, it will create the "Music" subfolder. If there are no audio files as described on the "IfExist" list, then the "Music" folder is not created.
This would prevent creation of empty folders, AND it would prevent having to use
IfExist, *.???
FileCreateDir, *FolderName*
for each and every single file extension name. That would be much larger, there has to be a better way. I'm not sure I understand LoopParse at all lol!

#7 nimda

nimda
  • Members
  • 4301 posts

Posted 01 May 2011 - 03:02 PM

Just use FileExist instead of legacy commands.
MsgBox % MultiExist("*.wav|*.ico")

MultiExist(patterns){
   Loop PARSE, Patterns,|
      If FileExist(A_LoopField)
         Return true
   return false
}
untested

or just multiple FileExists with the or operator

#8 Morpheus

Morpheus
  • Members
  • 397 posts

Posted 01 May 2011 - 06:18 PM

Loop, %Dir%
{
 if A_LoopFileExt in bmp,jpg,png
    Do Something
}

We need [Pseudo Code] Tags :-)

#9 aaronbewza

aaronbewza
  • Members
  • 466 posts

Posted 02 May 2011 - 09:29 PM

UPDATED to v1.1 in first post, with some changes:

*note* I could not get the LoopParse thing happening, I only encountered strange errors, so I chose reliability instead of taking chances.

Creates subfolders in selected folder and sorts files into them ONLY if those file extension names are found.
User is then given choices to move newly sorted documents, pictures and music
into User's regular Documents, Pictures and Music folders
(Uses My Documents, My Pictures and My Music folders in XP).

Subfolders now created in User-selected folder (if files exist):

Unsorted AHK Scripts
Unsorted Documents
Unsorted EXE Files
Unsorted Music
Unsorted PDF Files
Unsorted Pictures
Unsorted Video
Unsorted Zip Files

You can copy/paste the new script from the first post in this thread.

#10 Morpheus

Morpheus
  • Members
  • 397 posts

Posted 03 May 2011 - 11:46 AM

UPDATED to v1.1 in first post, with some changes:

*note* I could not get the LoopParse thing happening, I only encountered strange errors, so I chose reliability instead of taking chances.


Loop, FilePattern

not

Loop, Parse

It would simplify your script greatly.

#11 nimda

nimda
  • Members
  • 4301 posts

Posted 03 May 2011 - 03:48 PM

Morpheus: he means Loop Parse to get multiple filepatterns, as in my example. Loop Filepattern is usesless for say, both .exe and .ico

#12 sumon

sumon
  • Moderators
  • 1307 posts

Posted 03 May 2011 - 03:59 PM

And to clarify further (because I was helped looong ago, but they didn't explain Loop, Parse - a great thing to use):

Instead of:

FileMove, *.ahk, Unsorted AHK Scripts, 0 ; AutoHotkey Script Files
FileMove, *.ahk.bak, Unsorted AHK Scripts, 0 ; AutoHotkey Script Files
FileMove, *.bak, Unsorted AHK Scripts, 0 ; AutoHotkey Script Files
FileMove, *.pdf, Unsorted PDF Files, 0 ; Adobe PDF Files

You can do:

FileTypes := "ahk,ahk.bak,bak,pdf"
Loop, Parse, FileTypes, `, ; Parse using comma as a delimiter
FileMove, *.%A_LoopField%, Undosrted %A_LoopField% scripts, 0

Of course it's more helpful the longer the loop-list is. I think the time I was helped I wanted to "fade in" a Splashscreen, and had a long series of "WinSet, Transparency, 30" increasing and decreasing. The one who helped me changed that to parsing a string with "30|50|70|90|100|110|100|95|75|50|30|15" instead, simplifying the script a lot. I didn't understand what was going on... Thread

#13 aaronbewza

aaronbewza
  • Members
  • 466 posts

Posted 03 May 2011 - 08:26 PM

UPDATED to v1.2 (May 3rd 2011)

I figured out "Loop, Parse", thank you much for all your help, guys!

Updated script is in the first post on the thread :)
Thanks again!

#14 x79animal

x79animal
  • Members
  • 1021 posts

Posted 03 May 2011 - 09:07 PM

Version 1.2 is good, thanks for making this.

#15 Morpheus

Morpheus
  • Members
  • 397 posts

Posted 03 May 2011 - 09:35 PM

Morpheus: he means Loop Parse to get multiple filepatterns, as in my example. Loop Filepattern is usesless for say, both .exe and .ico


I was thinking that if I were doing it, I would use this code as I have posted above.

Loop, %Dir%
{
 if A_LoopFileExt in bmp,jpg,png
    Do Something
}

So not useless, but definitely different. I can see the advantage of mass moving files by extension, as opposed to one at a time as my method would require.

You could also use Glob by Lexikos and then parse that list, but it doesn't seem worth while to me.