-2

メディアPCで退屈なハウスキーピングを行うための簡単なスクリプトを実装したいのですが、どのスクリプト言語がこのタスクに役立つかわかりません。

私がやりたいことの擬似コードは次のとおりです。

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.

それでおしまい。時間の経過とともにさらに多くのことを行うために拡張したいと思うかもしれませんが。このタスクに使用する最も洗練されたスクリプトツールの提案はありますか?

ありがとう

4

2 に答える 2

1

PowerShellは、探していることを簡単に実行できます。Microsoftのスクリプトセンターをチェックしてください。これをすぐに打ち負かすのに十分な例とチュートリアルがあります。

于 2012-07-02T16:28:03.737 に答える
1

Macでも使用したいとおっしゃっていたので、Pythonをお勧めします。shutilandosモジュール(os.walkを参照)を使用すると、非常に簡単になります。topこれは、変数内のフォルダーから始まるすべてのファイルのサイズを取得する例です。

import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
    print root, "consumes",
    print sum(getsize(join(root, name)) for name in files),
    print "bytes in", len(files), "non-directory files"
    if 'CVS' in dirs:
        dirs.remove('CVS')  # don't visit CVS directories
于 2012-07-02T16:29:44.150 に答える