Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
d4cd8ba1
Commit
d4cd8ba1
authored
1 year ago
by
Karim Ahmed
Browse files
Options
Downloads
Patches
Plain Diff
add new script for renaming report folders
parent
711a864d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!884
[Webservice] Use leading zeros in usr/Reports folders
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
webservice/useful_scripts/rename_report_folders.py
+38
-0
38 additions, 0 deletions
webservice/useful_scripts/rename_report_folders.py
with
38 additions
and
0 deletions
webservice/useful_scripts/rename_report_folders.py
0 → 100644
+
38
−
0
View file @
d4cd8ba1
import
argparse
import
os
# Update runs into 4 digits integers e.g. r2 to r0002.
def
rename_folders_in_directory
(
directory_path
,
really
):
for
folder_name
in
os
.
listdir
(
directory_path
):
if
folder_name
.
startswith
(
'
r
'
)
and
folder_name
[
1
:].
isdigit
():
new_folder_name
=
'
r
'
+
folder_name
[
1
:].
zfill
(
4
)
old_path
=
os
.
path
.
join
(
directory_path
,
folder_name
)
new_path
=
os
.
path
.
join
(
directory_path
,
new_folder_name
)
if
really
:
os
.
rename
(
old_path
,
new_path
)
print
(
f
'
Renamed
{
folder_name
}
to
{
new_folder_name
}
'
)
else
:
print
(
f
'
Will rename
{
folder_name
}
to
{
new_folder_name
}
'
)
parser
=
argparse
.
ArgumentParser
(
description
=
'
Rename run folders.
'
)
parser
.
add_argument
(
'
--runs-directory
'
,
type
=
str
,
help
=
'
Directory path to the runs that needs to be renamed
'
,
required
=
True
,
)
parser
.
add_argument
(
'
--really
'
,
action
=
'
store_true
'
,
help
=
"
Actually make changes (otherwise dry-run)
"
)
args
=
parser
.
parse_args
()
if
args
.
runs_directory
:
runs_directory
=
args
.
runs_directory
else
:
assert
args
.
runs_directory
,
"
Specify the runs directory
"
rename_folders_in_directory
(
runs_directory
,
args
.
really
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment