This commit is contained in:
512song@sina.com committed 2025-04-04 20:13:20 +08:00
1 parent 462f74a745
commit b030391f58
1 file changed
+42 -2
+42 -2
View File
@@ -64,6 +64,46 @@
"#print(dict1)"
]
},
{
"cell_type": "markdown",
"id": "bb7b6152-0fad-4917-912a-379ed49c06f9",
"metadata": {},
"source": [
"## 批量修改文件名"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "d8abca28-6e1f-4f0a-a715-c1697cdf3f6a",
"metadata": {
"execution": {
"iopub.execute_input": "2025-04-04T12:09:07.760344Z",
"iopub.status.busy": "2025-04-04T12:09:07.759806Z",
"iopub.status.idle": "2025-04-04T12:09:08.370898Z",
"shell.execute_reply": "2025-04-04T12:09:08.369913Z",
"shell.execute_reply.started": "2025-04-04T12:09:07.760298Z"
},
"tags": []
},
"outputs": [],
"source": [
"import os,sys,shutil\n",
"import json\n",
"import glob\n",
"from pathlib import Path\n",
"\n",
"filepath = 'file/line/'\n",
"new = 'file/Line1/'\n",
"files = glob.glob(f'{filepath}*.SAC')\n",
"for fn in files:\n",
" fi_name =Path(fn).stem.split('_')[0]\n",
" n_name = Path(new,fi_name+'.SAC')\n",
" shutil.copyfile(fn,n_name)\n",
" \n",
" "
]
},
{
"cell_type": "code",
"execution_count": null,
@@ -1330,7 +1370,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
@@ -1344,7 +1384,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.3"
"version": "3.8.10"
}
},
"nbformat": 4,