Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Zheng Gaoshan
co-devTest
Commits
56da4a05
Commit
56da4a05
authored
May 16, 2025
by
Zheng Gaoshan
Browse files
Add new file
parent
aa9487b6
Changes
1
Show whitespace changes
Inline
Side-by-side
run.py
0 → 100644
View file @
56da4a05
import
os
import
shutil
def
main
():
# 定义初始路径和目标路径
source_dir
=
'/workspace/input/'
target_dir
=
'/workspace/output/'
# 确保源路径存在
if
not
os
.
path
.
exists
(
source_dir
):
print
(
f
"错误:源路径
{
source_dir
}
不存在。"
)
else
:
# 创建目标路径(如果不存在)
os
.
makedirs
(
target_dir
,
exist_ok
=
True
)
# 获取源路径下的所有文件(不递归子目录)
for
file_name
in
os
.
listdir
(
source_dir
):
source_file
=
os
.
path
.
join
(
source_dir
,
file_name
)
target_file
=
os
.
path
.
join
(
target_dir
,
file_name
)
# 只拷贝文件,忽略子目录
if
os
.
path
.
isfile
(
source_file
):
shutil
.
copy2
(
source_file
,
target_file
)
# copy2 保留元数据(如修改时间)
print
(
f
"已拷贝:
{
source_file
}
->
{
target_file
}
"
)
print
(
"拷贝完成。"
)
if
__name__
==
'__main__'
:
main
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment