AutoHotkey Community

It is currently May 25th, 2012, 4:44 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: September 30th, 2007, 6:11 pm 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: September 30th, 2007, 9:16 pm 
Offline

Joined: February 11th, 2005, 6:31 am
Posts: 174
Location: Germany
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 1st, 2007, 3:06 am 
Offline

Joined: September 28th, 2007, 3:56 am
Posts: 279
Location: New York
Thanks Andi, that fixed it. Funny what a slight mistake in code can do.


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], LazyMan, vinniel, Yahoo [Bot] and 16 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