DonationCoder.com Software > Post New Requests Here
IDEA: Command-line tool to move dir contents to existing subdirs
Cavalcader:
Hmm... are you really downloading dozens of installers etc. that could be auto-categorized each day?-brotherS (April 25, 2006, 04:12 PM)
--- End quote ---
No -- just trying to figure out a way to clear out a directory with files that are orphaned. Currently: 15,497 files, 1255 folders. :)
my memory is this came up in another discussion (in a renamer discussion?) and someone pointed us to a nice app for doing this.
-mouser (April 25, 2006, 04:12 PM)
--- End quote ---
That was me. 8) But BrotherS is right; it makes subfolders based on file names and moved the files into those folders. The result is that it leaves orphans when at least one of two things happen: 1. you get new files, or 2. you have subtle variations on the filename.
I keep the threshold set for two or more files to move, because if I let it act on just one then I end up with a bunch of dirs with a single file in each. The developer of the app I mentioned ( Directify!) has been swamped and so hasn't updated the tool from its 0.2 version in about a year and a half. ;)
I thinkCacheSort at https://www.donationcoder.com/forum/index.php?topic=1592.0 could be changed into what you want. Do you need a complete RegEx, or are wildcards sufficient?
-skrommel (April 25, 2006, 04:56 PM)
--- End quote ---
That's a great idea! Wildcards would be a great improvement over what I have now, heh! But if even a primitive RegEx is possible, that would allow much more control. Whatever you have time to mess with would be gratefully received. :D Even better is if there's a way for the app to make matches with less input, but I suspect that'd massively increase the size of the coding project.
The main issue is to match existing files to existing subdirs -- to join them with the rest of their type. I've got a boatload of utilities gathered over the years, mostly freeware (and I used to be a real regular at download sites, so I've seen pretty much every type of variation that's out there) but I've never seen anything that could make sense out of hundreds or thousands of orphan files that have mates in subdirs.
The only other consideration (just thought of it) is to somehow deal with filename collisions -- I guess "overwrite (yes/no/all/none/cancel)" is ideal if possible. If it uses a GUI then Windows XP and later already allow for a shift-click on the "no" button as "no to all" for the standard dialog.
lanux128:
Cavalcader: until the gurus of AHK come up with a better solution, why don't you try this -> File Sieve
File Sieve is a small tool that can take the files from a directory and copy or move them into a new folder, while creating subfolders from A-Z and sorting the files into them based on their name (first letter). The program can come handy if you want to organize files for archiving, or to put them on a CD.
--- End quote ---
IDEA: Command-line tool to move dir contents to existing subdirs
Source: www.snapfiles.com
Cavalcader:
Thanks, lanux128 -- it's a good idea, and I'd seen similar utilities, but it always struck me that an A-Z designation would tell me little more than the standard Windows alphabetic sort does. :)
Still, I'm sure that kind of function has its place, especially if you're making shareware CDs for a computer club or something! The program above has lots of potential -- I love the "smart creation" idea, where only folders are created that would contain files. But it would be a rare occasion indeed for someone to want empty A-Z directories. :D
Edit: I did some digging, and there's a version 3 beta 3 which seems to be getting much closer to what I'm looking for.
There's a new Delimiter mode that "creates a directory based on a delimiter within an item's name. Depending on the mode selected, the directory name is derived from an item's name as read from the start of the string up until the delimiter character, or it's read from the delimiter until the end of the name."
Another new mode is Substring: SpoilerPurpose
Destination directories are created from a substring contained within the
name of the processed items in specification to the options set below.
Options
StartIndex
This is the position of the first character to start at.
Length
This is the number of characters to return.
IncludeExtension
If True, then the extension will be taken into account when
obtaining a substring from an item's name.
Catch-All Directory
If a substring could not be obtained from an item's name,
the item will be placed into this directory.
Example
Item Names
VoiceMate Professional.exe
Hydrogen.exe
Poo.rar
Options
StartIndex: 1
Length: 5
IncludeExtension: False
Result
\Voice\VoiceMate Professional.exe
\Hydro\Hydrogen.exe
\Poo\Poo.rar
There's a Words mode too.
SpoilerPurpose
Items are sorted into directories based on the word(s) contained within
their name. The worded directories they are placed in depends on the
options set below.
Options
First Word
This is the number of the first word to use.
Total Words
This is the number of words that should be used for
creating the destination directory, starting from First Word.
Include Extension
If True, the extension of any files will be taken into account
as being an actual word itself.
TrimSpaces
Once the item's name has been broken down into words,
they may or may not contain extra spaces at either the start
or end of their names. Setting this option to True will remove
these spaces.
TrimCharacters
Any characters specified here will be trimmed from the start
and end of any words. Please note that each character is
treated separately and not as a string. So for example, entering
test will not remove "test" from the start and end of words, but
instead from the characters t, e, s, and t from the start and end.
Spaces cannot be specified on their own, this is why the
TrimSpaces option exists.
Catch-All Directory
If a word could not be obtained from the item's name,
then it will be placed into this directory.
Examples
Item names
My Test File.exe
Another Test File Here.exe
And Finally The Last One.rar
Options
First Word: 2
Total Words: 2
Include Extension: False
Result
Test File\My Test File.exe
Test File\Another Test File Here.exe
Finally The\And Finally The Last One.rar
I can see I'm going to have to spend some time experimenting with this puppy. I still don't think it does the matching to already-present subdirs, though, but thanks for the tip!
app103:
As someone that recently manually sorted 30G of songs by artist, and then by album, while merging the contents of 2 pc's to a 3rd pc, I really could have used a tool like this myself...and I know plenty more would have a use for it too.
Maybe I will wait and see how this goes before attempting to merge the 2 graphics collections.
Great idea, Cavalcader!
Cavalcader:
Thanks, app103! Lanux128, I spent some time with it, and for what I'm describing it's not quite as powerful as the Directify! tool except that it's got a GUI. It will create a boatload of directories, but it doesn't have a way to only create dirs if there's more than X number of candidates, and it doesn't have any way to fix the results (take orphaned, single-file dirs and group 'em again). The result is that you get a lot of dirs, but no telling how the contents are grouped. The preview or "simulation" mode is helpful, but there's no way to sort it. It defaults to the existing alpha sort based on the original paths, which isn't much help when you're trying out new paths to see how well they work. ;)
That said, it's got some other really powerful features, including being able to recurse into subdirs for its operations. It'll solve a lot of file "housekeeping" chores, but not the one described in this thread (at least not yet). It may end up including this capability as well, but I noticed two things that make me wonder how far it'll go: there's no way to edit the existing "methods" (like A-Z, delimiter, word, etc.) or create new ones, although there's a mention in the help file that it might be added to a future version. That may be a pretty trivial consideration, but I also noted that the discussion form referred to in the help file from January of this year is closed, at least temporarily. This says to me that the author may have run into some personal issues taking him away from coding and his website for now. (Then again, I could be way off!) :tellme:
Lotsa hobbyist (or even pro) coders tend to suffer burnout after awhile -- it's tough work on a good day, wrestling with attempts at logical code and dealing with cryptic error messages, operating system or development system quirks, and who knows what else. When you jump online and try to interact with the world along the way (feature requests, help demands and so on -- some people aren't even nice about their requests and won't give enough info about their situation) it can be a heckuva lot to deal with. Here's hoping he's able to keep going with the project!
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version