 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Sun Sep 30, 2007 5:11 pm Post subject: Help on file/folder recursing |
|
|
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 |
|
 |
Andi
Joined: 11 Feb 2005 Posts: 173 Location: Germany
|
Posted: Sun Sep 30, 2007 8:16 pm Post subject: |
|
|
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 |
|
 |
ribbs2521
Joined: 28 Sep 2007 Posts: 273 Location: New York
|
Posted: Mon Oct 01, 2007 2:06 am Post subject: |
|
|
| Thanks Andi, that fixed it. Funny what a slight mistake in code can do. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|