zu nächst einmal, ich habe keinerlei Erfahrung mit Phyton. Deshalb bitte ich euch um Hilfe bei der Lösung einer Aufgabe.
Ich sitze jetzt schon seit mehreren Stunden vor dem PC und durchsuche google am laufenden Band aber ich komme zu keiner Lösung.
Der Code ist schon fast fertig aber ich komme trotzdem nicht weiter.
Zur Info:
Das Skript liegt in einem Ordner in dem 3 Ordner sind : Folder 1-3. In jedem dieser Ordner befinden sich mehrere Dateien mit unterschiedlicher Endung. (z.b.: .DAT ; . Dat ; .dAt ; .date ; usw. ) Es sollen mit dem Skript alle Endungen kleingeschrieben werden, ohne das der Dateiname in irgendeiner Weise verändert wird. (z.b.: sDewsS.DAT zu sDewsS.dat )
Danke schon einmal.
Hier der Code:
Code: Alles auswählen
## Given is a random folder-structure in "data".
## Contained files have random suffixes.
##
## This script should recursively walk down the folder-structure
## and normalize all filenames in a way, that:
## -all suffixes are in lower case
## -the filename (prefix) stays untouched
##
## A good starting point is to look at python's "os"-module.
## During development the debugger will come in handy;
## import the "pdb"-module and set break-points with "pdb.set_trace()"
## you can type pure python-code at the resulting prompt.
##
## To run the script, simply type "python normalizeFiles.py" in the console of your choice.
##
## Good luck.
##
##operate on this path (please change it according to your needs):
WPATH = '/home/haagen/projects/pythonProjects/smallPythonAssessment/data'
##import neccessary modules
import os
import pdb
## functions
##
## --> insert more functions here
##....
def normalizeFiles(_path):
""" This is the main routine;
walks down the filesystem-tree starting at _path
and tranforms file-suffixes to lower case
returns the list of changed filenames
"""
#pdb.set_trace()
buffer = []
##insert code here
##....
return buffer
## /functions
## call "normalizeFiles" and print the results:
changedFiles = normalizeFiles(WPATH)
for cF in changedFiles:
print cF