Something that drives me nuts is mixed case names all over a large directory tree and save manually renaming all of them, I normally don't bother but I need to do this from time to time so I wrote a toy that seems to do the job fine. It recurses up and down a directory tree renaming all of the files from its starting location upwards in lower case.
[attachment deleted by admin]
hutch--
Another one that drives me nuts is the way that directory dates never reflect anything useful except to remind you of the last system catastrophy and recovery--something I usually don't want reminders of...
And it's the same date on EVERY directory! :eek
So why not make your recursive scan set the date/time of every directory to the date/time of the oldest entry inside it (using depth-first recursion). The result is a directory tree that is more informative and transparent.
just a thought...
[ actually, I just wanted to see if I get two stars on post #50... :dance: ]
:bg
The two stars are definetely up.
The sugestion sounds like a "touch" utility with directory only filtering. Then set them all to 31 12 2099.
Hi, was wading through the posts for "Recursive Directory" scanning and found this one. :cheekygreen:
I had also done a couple of utilities for the same purposes as mentioned here. Good experience while learning assembly I must say! :dance:
These are a "UI" version. :lol
The shantools (for want of a better word), was required to names my collection of MP3 files amongst others. :toothy
The Touch32 was good to learn about file time and offset from GMT and stuff like that.
Edited here:
Realised that I had no explanation whatsoever along with the EXEs attached before. :eek :dazzled:
So...writing the "documentation", this time! :bg (Also present as text files inside the zip files).
QuoteShantanu's Tools (for want of a better name) :)
----------------
A tiny utility for renaming files/folders to UPPERCASE/lowercase/ProperCase.
How to install:
Drop "shantools.exe" in some usual folder (like C:\WINDOWS) and run it once.
When you run it for the first time, it will ask to create a right-click menu
entry (for Windows Explorer).
After that it should be available in Windows Explorer right-click directly.
The "Additional Options" is currently left blank (till I think of some options
to put there! :) )
...and for Touch32
Quote
Touch32
-------
A touch utility for Win32 (UI).
Does what the name says. Optionally can recurse subdirectories.
Can modify Created/Modified/Accessed times for the files and directories.
* Minor check to try and modify DIRECTORY times ONLY under WinNT systems (NT/2k/XP..)
* Silently fail (NO popup MessageBox)
[attachment deleted by admin]
Hi hutch,
wanted to ask (verify) :bg about your algo: :green2
1. It would skip ALL directories beginning with a ".", right?
2. About checking the dir's attribute, your code seems to be checking ONLY for the "DIRECTORY" attribute, what if the dir is HIDDEN (DIR+HIDDEN)?
3. Would "setting current dir" be a "heavier" operation than "string manipulation"?
Any views about the code posted below?:
.data?
szCurrentPath BYTE MAX_PATH dup(?) ;this MUST be set to something valid before the recursive loop is called for the first time
szTemp BYTE MAX_PATH dup(?)
wfd WIN32_FIND_DATA <>
hFind HANDLE ?
bContinueFind BOOL ?
...
.code
DoRecursiveScan proc private
invoke wsprintf, offset szTemp,SADD("%s\*.*"),offset szCurrentPath
invoke FindFirstFile, offset szTemp, offset wfd
.if eax == INVALID_HANDLE_VALUE
mov eax,FALSE
ret
.endif
mov hFind,eax
mov bContinueFind, TRUE
mov esi, offset wfd.cFileName
.if byte ptr [esi] == '.' && byte ptr [esi+1] == 0 ;entry == "."
;"." entry found means NOT ROOT directory and next entry MUST BE ".."
;so...eat the ".." entry up :)
invoke FindNextFile,hFind, offset wfd
;make the scan point to the first valid file/directory (if any) :)
invoke FindNextFile,hFind, offset wfd
mov bContinueFind,eax
.endif
;"." entry NOT found, so it is ROOT directory and as FindFirstFile returned something,
;atleast one file entry exists
.while bContinueFind == TRUE
;could use "test" too
mov eax,wfd.dwFileAttributes
and eax,FILE_ATTRIBUTE_DIRECTORY
.if eax == FILE_ATTRIBUTE_DIRECTORY
;do stuff with the directory here
;the SADD macro is from the macros.asm
invoke wsprintf, offset szTemp,SADD("%s\%s"),
offset szCurrentPath,offset wfd.cFileName
invoke lstrcpy,offset szCurrentPath,offset szTemp
push hFind
invoke DoRecursiveScan
pop hFind
invoke GoParent, offset szCurrentPath
.else
;do stuff with file
.endif
invoke FindNextFile, hFind, offset wfd
mov bContinueFind,eax
.endw
invoke FindClose,hFind
mov eax,TRUE
ret
DoRecursiveScan endp
;chops off stuff after last '\'
;completely unoptimized :) :) (working version only)
GoParent proc lpszPath:LPTSTR
push esi
mov esi,lpszPath
.while byte ptr [esi] != 0
inc esi
.endw
.while byte ptr [esi] != '\'
dec esi
.endw
mov byte ptr [esi],0
pop esi
ret
GoParent endp
hutch total commander has built in multi rename tool, in some dir alt+F7 search without anything, feed to listbox,select dirs and ctrl+m
you can rename by [N] name [N3-] all since 3rd letter, [C] by counter also change all to upper, all lower,First of every word Upper
Human,
Many programs use a basic recursive algo to climb up and down a tree, its not much use though if you need the capacity in your own program. Shantanu's code looks fine.
QuoteShantanu's code looks fine.
Thanks! :green :8)
shantanu,
A very nice addition to my toolbox. Thank you very much for sharing! :U
Paul
CodeWarp,
One of the examples in the MASM32 Project is a touch utility.
Paul
To PBrennick,
Huh? What? Confused!!! :(
Had a quick glance, that code doesn't do recursive, right? Also it doesn't modify DIRS.
And, NO...I have not used that code...while writing my Touch32(c) :8) :toothy :green
The one you can really have fun with is recursive file and directory delete but its wise to test it on a trashable partition as you can wipe out an entire partition very easily. The "touch" utility in the example code works on one dir at a time. I wrote the original as a recursive and probably still have it around but its another that you can make a mess of things with where the single dir version is pretty safe.