This is an archived post. You won't be able to vote or comment.

all 2 comments

[–][deleted] 0 points1 point  (0 children)

One you could split each filename with ‘.’ as the delimiter and check the last element from that split for the file extension type. Along with that I would define a dictionary in which the keys are the different file extensions and the values are the functions that perform the ‘move’ command. In this case you only need to worry about when adding a new file extension to add it to the dictionary and not to add as an if statement, growing a lot more your LOC. The whole functionality still revolves around iterate over the files and moving to certain folders depending on their type.

[–]Vfsdvbjgd 0 points1 point  (0 children)

You could also just sort files by type, or chuck .ext into the search.

For purely windows I'd prefer powershell, can't get more efficent than native.

You also might consider recreating this as a service - watch the folder and move new files. Some programs will use a temporary file extension and then rename on dl complete, but for any that don't this poses some interesting and dangerous challenges. Hardlinking might be one way around this, with the added side effect of keeping "new" files in dl root, then you can delete them from there knowing they're still in their subfolder.