在TotalCmd软件中,调用如下 python 脚本,可在当前文件夹下建立形如"YYYY_MM_DD"的目录。
#
-*- coding: utf-8 -*-
#
[email protected]
#
MakeDateFolder.py
#
在输入路径处创建一个以当前日期命名的文件夹
def
GetDateString():
from
datetime
import
date
todayStr
=
date.today().strftime(
"
%Y_%m_%d
"
)
return
todayStr
def
MakeDateFolder( inFolderName ):
import
os
if
os.path.isdir( inFolderName ):
newFolderName
=
inFolderName
+
'
\\\\
'
+
GetDateString()
print
(newFolderName)
if
os.path.isdir( newFolderName ):
print
(newFolderName,
"
Exists already
"
)
else
:
os.mkdir( newFolderName )
print
(newFolderName,
"
Create OK
"
)
else
:
print
(inFolderName,
"
not exists, script stop
"
)
#
debug
#
MakeDateFolder("F:\\\\temp")
#
MakeDateFolder("F:\\\\temp\\\\yank")
#
-----------------------------------------------------------------
#
接受输入,调用创建函数
def
inputMain():
import
sys
if
len(sys.argv)
>=
2
:
currentDir
=
sys.argv[
1
]
else
:
print
(
"
Please Input Folder Name:
"
)
currentDir
=
raw_input()
MakeDateFolder(currentDir)
print
(
"
Any Key To Return
"
)
currentDir
=
raw_input()
if
__name__
==
"
__main__
"
:
inputMain()
然后在TotalCmd中创建一个新的开始菜单操作,Command 就是 该Python文件,Parameters 是 %p,Start Path 是 . 。这样就可以在TotalCmd中运行该脚本,会在TC的当前目录下建立形如(YYYY_MM_DD)的目录。