I want to implement a simple script to do some boring housekeeping on my media pc, but am not sure what scripting language would lend itself to this task.
Pseudocode for what I want to do is:
1) Scan a directory for sub directories matching a name like:
"Foo 1x01 bar"
"Foo 1x02 bar"
or
"Foo s01e01 bar"
"Foo s01e02 bar"
2) Then for each matching sub directory:
- Make a directory "Foo" if it doesn't already exist.
- Copy the largest file under the matching sub directory into "Foo".
- Delete the matched sub directory and anything left in it.
That’s it. Although I might want to extend it to do more over time. Any suggestions for the most elegant scripting tool to use for this task?
Thanks
I’d recommend Python, as you stated that you want to use it on your Mac too.
Using the the
shutilandosmodules (look at os.walk), it should be pretty easy.here’s an example that gets the size of all of the files starting from the folder in the
topvariable.