I have spent hours today searching for something which *should*n be utterly simple.
It is simply putting the current working directory into a variable so that it could be manipulated as part of a renaming process. Finally, it is:
currdir = os.path.split(os.getcwd())[1]
print(currdir)
My first question is: Is there anything simpler? Without the baggage of walking to root.
something like os.path.just_this_dir?
My next question is the nature of the shutil.move statement.
would somethinmg like:
newdir = re.sub(r'('_'),(' '),currdir)
shutil.move(currdir,newdir)
work?
In Perl direcotiries are moved the same way as files. And move is also used in renaming.
One of the issue I am having is that in Python, os ops functions do not seem to recognize the . operator as current dir. Or at least the way i tried it.
I can, of course 'join' to the parent directories to get an absolute path for file/dir operations, but would prefer a simpler mechanism as the moves I will be doing are pretty much all relative to the current dir.
In other words, is:
shutils.move(./foo,./bar)
kosher?
It is simply putting the current working directory into a variable so that it could be manipulated as part of a renaming process. Finally, it is:
currdir = os.path.split(os.getcwd())[1]
print(currdir)
My first question is: Is there anything simpler? Without the baggage of walking to root.
something like os.path.just_this_dir?
My next question is the nature of the shutil.move statement.
would somethinmg like:
newdir = re.sub(r'('_'),(' '),currdir)
shutil.move(currdir,newdir)
work?
In Perl direcotiries are moved the same way as files. And move is also used in renaming.
One of the issue I am having is that in Python, os ops functions do not seem to recognize the . operator as current dir. Or at least the way i tried it.
I can, of course 'join' to the parent directories to get an absolute path for file/dir operations, but would prefer a simpler mechanism as the moves I will be doing are pretty much all relative to the current dir.
In other words, is:
shutils.move(./foo,./bar)
kosher?