1
N.A.N.Y. 2010 / Re: pyrohacker
« on: July 17, 2016, 04:52 AM »
Hi, I got a slightly modded version of your code.
I used this before and thought I would sort my download-folder now, but it didn't work today (Windows 10).
Thought I would see if there was an update for it, and read that you lost it.
Also, I wanted only the year, so I put together a little bat script instead.
Used some bits from these 2 to get it working so it will not move any .bat:
http://stackoverflow.com/a/22222204 [Batch file to move file based on Month & Year on Date modified to folder with YYYY_MM]
http://stackoverflow.com/a/863627 [In a batch file, how do I delete all files NOT of a certain type]
Here's the code for your script (modded for YYYY-MM)
I used this before and thought I would sort my download-folder now, but it didn't work today (Windows 10).
Thought I would see if there was an update for it, and read that you lost it.
Also, I wanted only the year, so I put together a little bat script instead.
Used some bits from these 2 to get it working so it will not move any .bat:
http://stackoverflow.com/a/22222204 [Batch file to move file based on Month & Year on Date modified to folder with YYYY_MM]
http://stackoverflow.com/a/863627 [In a batch file, how do I delete all files NOT of a certain type]
Code: Visual Basic [Select]
- @echo off
- cls
- choice /c yn /t 10 /d n /m "move all files divided by year?"
- if errorlevel 2 goto stop
- for %%f in ("%cd%\*") do if not %%~xf==.bat (
- for /f "tokens=1 delims=- " %%a in ("%%~tf") do (
- if not exist "%cd%\%%a" mkdir "%cd%\%%a"
- move "%%~f" "%cd%\%%a"
- )
- )
- cls
- echo all done!
- timeout 10
- :stop
- exit
Here's the code for your script (modded for YYYY-MM)
Code: Autohotkey [Select]
- /*
- SubDiv
- created by pyrohacker on the D.C. Forum
- as a NANY 2010 Entry.
- */
- #SingleInstance Force
- SetWorkingDir %A_ScriptDir%
- ; Set up GUIs and variables
- Setup:
- Separator=%SeparatorSelection%
- Cleanup=%CleanupSetAt%
- ; Create the settings dialog
- Start:
- ; Create the Main Actions Dialog
- Pause On
- Actions:
- Pause Off
- Pause On
- SortNow:
- Pause Off
- NewFiles = %NewFiles%%A_LoopFileName%`n
- UpdateFolders()
- if Separator = 1
- UnderscoreSort()
- if Separator = 2
- HyphenSort()
- GoSub Problems
- MsgBox Finished sorting %A_WorkingDir%!
- GoSub EndProg
- UpdateFolders()
- {
- global
- If (Cleanup == 1) {
- {
- Size = 0
- {
- Size += %A_LoopFileSize%
- }
- ;MsgBox Size of %A_LoopFileName% is %A_LoopFileSize% bytes.
- If (Size < 1) {
- }
- }
- }
- Return
- }
- HyphenSort()
- {
- global
- {
- NowTime := SortTime
- FileCreateDir %FolderName%
- EverRun=1
- }
- Return
- }
- UnderscoreSort()
- {
- global
- {
- NowTime := SortTime
- FileCreateDir %FolderName%
- EverRun=1
- }
- Return
- }
- ShowSettings:
- Pause Off
- Pause On
- SendSettings:
- Separator=%SeparatorSelection%
- Cleanup=%CleanupSetAt%
- if (RecurseSetAt = 1) and (RecurseWarning = 0)
- {
- RecurseWarning=1
- IfMsgBox No
- GoSub ShowSettings
- }
- Recursive=%RecurseSetAt%
- Gosub Start
- Problems:
- 3GuiClose:
- return
- EndProg:
- 2GuiClose: