AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Help on file/folder recursing

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
ribbs2521



Joined: 28 Sep 2007
Posts: 273
Location: New York

PostPosted: Sun Sep 30, 2007 5:11 pm    Post subject: Help on file/folder recursing Reply with quote

I am having issues with my program that takes all .jpg files and creates folders to sort them by creation date. Any time there are files in sub folders (provided subfolders are selected) it grabs the creation date and file names. If the files are in the subfolders it creates a folder for the createion date but doesn't copy the files. Anyone know why?


Code:

;;;Global Variables;;;
List =
i = 0
Errors = 0
Subs = 0


FileSelectFolder, PictureFolder, C:\Documents and Settings\Geoff\My Documents,, Select the picture folder
If ErrorLevel
  ExitApp

MsgBox, 4, SubFolders?, Would you like to include subfolders?
IfMsgBox, Yes
  Subs = 1

Loop, %PictureFolder%\*.jpg,, %Subs%
{
FormatTime, Month, %A_LoopFileTimeCreated%, M
FormatTime, Year, %A_LoopFileTimeCreated%, yyyy
FormatTime, CreationTime, %A_LoopFileTimeCreated%, M-dd-yy
List = %List%%A_LoopFileName%  %CreationTime%`n

IfExist, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
 {
 FileCopy, %PictureFolder%\%A_LoopFileName%, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
   If ErrorLevel,
    {
    Errors++
    }
   Else,
    {
    i++
    }
 }
Else,
 {
 FileCreateDir, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
 FileCopy, %PictureFolder%\%A_LoopFileName%, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
   If ErrorLevel,
    {
    Errors++
    }
   Else,
    {
    i++
    }
 }
}

If List =
 {
 MsgBox, There were no files in that folder
 }
Else,
 {
 MsgBox, %i% files moved successfully!`n%Errors% files were unable to be moved.
 }

MsgBox, The files in this folder are:`n%List%




ExitApp

^DELETE::ExitApp
Back to top
View user's profile Send private message
Andi



Joined: 11 Feb 2005
Posts: 173
Location: Germany

PostPosted: Sun Sep 30, 2007 8:16 pm    Post subject: Reply with quote

I think this would do it. Please try it with A_LoopFileFullPath.

Code:

;;;Global Variables;;;
List =
i = 0
Errors = 0
Subs = 0


FileSelectFolder, PictureFolder, C:\Documents and Settings\Geoff\My Documents,, Select the picture folder
If ErrorLevel
  ExitApp

MsgBox, 4, SubFolders?, Would you like to include subfolders?
IfMsgBox, Yes
  Subs = 1

Loop, %PictureFolder%\*.jpg,, %Subs%
{
FormatTime, Month, %A_LoopFileTimeCreated%, M
FormatTime, Year, %A_LoopFileTimeCreated%, yyyy
FormatTime, CreationTime, %A_LoopFileTimeCreated%, M-dd-yy
List = %List%%A_LoopFileName%  %CreationTime%`n

IfExist, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
 {
 FileCopy, %A_LoopFileFullPath%, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
   If ErrorLevel,
    {
    Errors++
    }
   Else,
    {
    i++
    }
 }
Else,
 {
 FileCreateDir, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
 FileCopy, %A_LoopFileFullPath%, C:\Documents and Settings\Geoff\My Documents\My Pictures\%Month%-%Year%
   If ErrorLevel,
    {
    Errors++
    }
   Else,
    {
    i++
    }
 }
}
If List =
 {
 MsgBox, There were no files in that folder
 }
Else,
 {
 MsgBox, %i% files moved successfully!`n%Errors% files were unable to be moved.
 }

MsgBox, The files in this folder are:`n%List%




ExitApp

^DELETE::ExitApp
Back to top
View user's profile Send private message
ribbs2521



Joined: 28 Sep 2007
Posts: 273
Location: New York

PostPosted: Mon Oct 01, 2007 2:06 am    Post subject: Reply with quote

Thanks Andi, that fixed it. Funny what a slight mistake in code can do.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group