123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /*
- * -- Move Image Files using 'Image Files List.txt'--
- *
- * Requires images subfolder to exist in current directory
- *
- * ImageFileList - List of file names from glife.txt and Auto List
- * UsedImageFolder - Folder to move images in ImageFileList
- * UnUsedImageFolder - Folder to move images not in ImageFileList
- * SourceFolder - Folder with images
- *
- *
- * WD: Jul 2015
- *
- *
- */
-
-
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #Warn ; Enable warnings to assist with detecting common errors.
- SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
- SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- ImageFileList = Image List - Used.txt
- UsedImageFolder = Images, Used
- UnUsedImageFolder = Images, Un-Used
- SourceFolder = images
- FileEncoding, UTF-16
- ;-- backup files and delete --
- IfNotExist %ImageFileList%
- {
- MsgBox, 16, Move Image Files, Unable to locate "%ImageFileList%" in "%A_WorkingDir%", 10
- Exit
- }
- IfNotExist %UsedImageFolder%
- {
- FileCreateDir, %UsedImageFolder%
- }
- IfNotExist %UnUsedImageFolder%
- {
- FileCreateDir, %UnUsedImageFolder%
- }
- ; -- load data from file --
- FileRead, Images, %ImageFileList%
- Images := StrReplace(Images, "/", "\") ;; Use correct Win path seperator
- ; -- Parse data one line at a time --
- Loop, Parse, Images, `n, `r ; Specifying `n prior to `r allows both Windows and Unix files to be parsed.
- {
- if trim(A_LoopField) = "" ;; Skip blank line
- continue
-
- IfExist, %A_LoopField%
- {
- ; -- Create Dir if id dosn't exist --
- SplitPath, A_LoopField, FileName, FileDir
- IfNotExist %UsedImageFolder%\%FileDir%
- {
- FileCreateDir, %UsedImageFolder%\%FileDir%
- if (ErrorLevel)
- {
- MsgBox, 48, Move Image File, FileCreateDir Error:`n`nFailed to create '%UsedImageFolder%\%FileDir%'`n`nErrorLevel: '%ErrorLevel%'`nLastError: '%A_LastError%'
- }
- }
-
- ; -- move file --
- FileMove, %A_LoopField%, %UsedImageFolder%\%FileDir%
- if (ErrorLevel)
- {
- MsgBox, 48, Move Image File, FileMove Error:`n`nFailed to move '%A_LoopField%' to '%UsedImageFolder%\%FileDir%'`n`nErrorLevel: '%ErrorLevel%'`nLastError: '%A_LastError%'
- }
- }
- else ; -- File dosn't exist --
- {
- MsgBox, 64, Move Image Files, Unable to locate file : '%A_LoopField%', 5
- }
- }
- ; -- Rename Images folder to unused Images folder --
- IfExist %SourceFolder%
- {
- FileMoveDir, %SourceFolder%, %UnUsedImageFolder%\%SourceFolder%
- if (ErrorLevel)
- {
- MsgBox, 48, Move Image File, FileMoveDir Error:`n`nFailed to move '%SourceFolder%' to '%UnUsedImageFolder%\%SourceFolder%'`n`nErrorLevel: '%ErrorLevel%'`nLastError: '%A_LastError%'
- }
-
- ; -- Rename Used Images folder to Images folder --
- else IfNotExist %SourceFolder%
- {
- FileMoveDir, %UsedImageFolder%\%SourceFolder%, %SourceFolder%
- if (ErrorLevel)
- {
- MsgBox, 48, Move Image File, FileMoveDir Error:`n`nFailed to move '%UsedImageFolder%\%SourceFolder%' to '%SourceFolder%'`n`nErrorLevel: '%ErrorLevel%'`nLastError: '%A_LastError%'
- }
- else
- {
- FileRemoveDir, %UsedImageFolder%, 0 ;; Delete Empty Folder
- }
- }
- }
|