-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated file organizer and added notebook
- Loading branch information
Showing
7 changed files
with
168 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Organize files based on their extensions" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from pathlib import Path\n", | ||
"\n", | ||
"from impreproc.files import Organizer\n", | ||
"\n", | ||
"# Define parameters\n", | ||
"# Note that in Jupyter Notebooks, the path are relative to the notebooks folder!" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Single directory - move files\n", | ||
"imdir = \"../data/conversion/DJI_202303031031_001\"\n", | ||
"recursive = False\n", | ||
"inplace = True\n", | ||
"organizer = Organizer(recursive=recursive, inplace=inplace)\n", | ||
"organizer.organize(imdir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Single directory - copy files\n", | ||
"imdir = \"../data/conversion/DJI_202303031031_001\"\n", | ||
"recursive = False\n", | ||
"inplace = False\n", | ||
"organizer = Organizer(recursive=recursive, inplace=inplace)\n", | ||
"organizer.organize(imdir)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Batch on multiple directories - move files\n", | ||
"imdir = \"../data/conversion\"\n", | ||
"recursive = True\n", | ||
"organizer = Organizer(recursive=recursive)\n", | ||
"organizer.organize(imdir)\n" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"True" | ||
] | ||
}, | ||
"execution_count": 3, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"# Define your own organization rules\n", | ||
"\n", | ||
"RULES = {\n", | ||
" \"raw\": [\"dng\", \"cr2\", \"nef\", \"arw\"],\n", | ||
" \"jpg\": [\"jpg\", \"jpeg\"],\n", | ||
" \"png\": [\"png\"],\n", | ||
" \"tif\": [\"tif\", \"tiff\"],\n", | ||
" \"dji_gnss\": [\"obs\", \"nav\", \"bin\", \"mrk\"],\n", | ||
" \"videos\": [\"mp4\", \"mkv\", \"avi\", \"mov\", \"wmv\", \"flv\", \"webm\"],\n", | ||
" \"documents\": [\"pdf\", \"docx\", \"pptx\", \"xls\", \"doc\", \"ppt\"],\n", | ||
" \"audios\": [\"mp3\", \"wav\", \"ogg\", \"flac\", \"aac\", \"wma\", \"m4a\"],\n", | ||
" \"archives\": [\"zip\", \"rar\", \"7z\", \"tar\", \"gz\", \"pkg\", \"deb\", \"rpm\"],\n", | ||
" \"executables\": [\"exe\", \"msi\", \"apk\", \"app\", \"bat\", \"sh\"],\n", | ||
" \"code\": [\"py\", \"js\", \"html\", \"css\", \"cpp\", \"c\", \"java\", \"go\", \"php\", \"rb\", \"json\", \"xml\", \"sql\"], \n", | ||
"}\n", | ||
"\n", | ||
"imdir = \"../data/conversion/DJI_202303031031_001\"\n", | ||
"organizer = Organizer(rules=RULES)\n", | ||
"organizer.organize(imdir)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "imgpreproc", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.12" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters