パイソン 2.5.1
http://www.cgsecurity.org/wiki/After_Using_PhotoRec
PhotoRec を実行したところ、ファイルの種類を独自のフォルダーに分類する方法として指定されたコードが、このエラーで返されます。変更方法に関する提案はありますか?ありがとう :
【EDIT2:2点:
- この質問は、コードの「使用法」であり、プログラミングの質問ではないため、投票されませんでした。それはコーディングの質問として資格がありますか? 私はそう主張します。
他の人のためにパラメータの必要性を明確にするために、コードの元のページに戻って編集しました。]
gyaresu$ python recovery.py トレースバック (最新の呼び出しが最後): ファイル "recovery.py"、8 行目、ソース = sys.argv[1] 内 IndexError: リスト インデックスが範囲外です
脚本:
#!/usr/bin/env python
import os
import os.path
import shutil
import string
import sys
source = sys.argv[1]
destination = sys.argv[2]
while os.path.exists(source) != True:
source = raw_input('Enter a valid source directory\n')
while os.path.exists(destination) != True:
destination = raw_input('Enter a valid destination directory\n')
for root, dirs, files in os.walk(source, topdown=False):
for file in files:
extension = string.upper(os.path.splitext(file)[1][1:])
destinationPath = os.path.join(destination,extension)
if os.path.exists(destinationPath) != True:
os.mkdir(destinationPath)
if os.path.exists(os.path.join(destinationPath,file)):
print 'WARNING: this file was not copied :' + os.path.join(root,file)
else:
shutil.copy2(os.path.join(root,file), destinationPath)