Remove .DS_Store files and update .gitignore
This commit is contained in:
@@ -13,7 +13,7 @@ def clean(item):
|
|||||||
#print(x)
|
#print(x)
|
||||||
if isfile(x):
|
if isfile(x):
|
||||||
#sort the file
|
#sort the file
|
||||||
if ".db" in x or ".lrprev" in x or ".LRV" in x or ".THM" in x or ".lrcat" in x:
|
if x.split(".")[-1].lower() in ["db" ,"lrprev" ,"lrv" , "thm", "lrcat", "txt", "xmp"]:
|
||||||
os.remove(x)
|
os.remove(x)
|
||||||
elif ".py" in x:
|
elif ".py" in x:
|
||||||
pass
|
pass
|
||||||
|
|||||||
110
video-edits.ipynb
Normal file
110
video-edits.ipynb
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import os\n",
|
||||||
|
"import shutil\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"# Define the root folders\n",
|
||||||
|
"moments_folder = '/Volumes/home/Photos/Moments'\n",
|
||||||
|
"videos_folder = '/Volumes/home/Photos/Videos'\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 3,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"# Create the Videos folder if it doesn't exist\n",
|
||||||
|
"if not os.path.exists(videos_folder):\n",
|
||||||
|
" os.makedirs(videos_folder)\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 5,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"\n",
|
||||||
|
"# Walk through the Moments folder structure\n",
|
||||||
|
"for root, dirs, files in os.walk(moments_folder):\n",
|
||||||
|
" for file in files:\n",
|
||||||
|
" # Check if the file is a video (you can adjust the extension check as needed)\n",
|
||||||
|
" if file.lower().endswith(('.mp4', '.mov', '.avi', '.mkv')):\n",
|
||||||
|
" # Get the relative path from the Moments folder\n",
|
||||||
|
" rel_path = os.path.relpath(root, moments_folder)\n",
|
||||||
|
" # Create the corresponding folder structure in Videos\n",
|
||||||
|
" video_folder = os.path.join(videos_folder, rel_path)\n",
|
||||||
|
" if not os.path.exists(video_folder):\n",
|
||||||
|
" os.makedirs(video_folder)\n",
|
||||||
|
" # Move the video file to the corresponding folder in Videos\n",
|
||||||
|
" #print(f\"Would Have Moved {os.path.join(root, file)} to {os.path.join(video_folder, file)}\")\n",
|
||||||
|
" shutil.move(os.path.join(root, file), os.path.join(video_folder, file))"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 14,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"root_dir = videos_folder\n",
|
||||||
|
"#Go through folders and add a leading zero months and days folders\n",
|
||||||
|
"for year_dir in os.listdir(root_dir):\n",
|
||||||
|
" if year_dir == \".DS_Store\":\n",
|
||||||
|
" continue\n",
|
||||||
|
" year_path = os.path.join(root_dir, year_dir)\n",
|
||||||
|
" for month_dir in os.listdir(year_path):\n",
|
||||||
|
" if month_dir == \".DS_Store\":\n",
|
||||||
|
" continue\n",
|
||||||
|
" month_path = os.path.join(year_path, month_dir)\n",
|
||||||
|
" new_month_dir = month_dir.zfill(2) # add leading zero to month dir\n",
|
||||||
|
" #print(f\"Would have renamed Month folder from {os.path.join(year_path, month_dir)} to {os.path.join(year_path, new_month_dir)}\")\n",
|
||||||
|
" #os.rename(month_path, os.path.join(year_path, new_month_dir))\n",
|
||||||
|
" for day_file in os.listdir(os.path.join(year_path, new_month_dir)):\n",
|
||||||
|
" if day_file == \".DS_Store\":\n",
|
||||||
|
" continue\n",
|
||||||
|
" day_path = os.path.join(year_path, new_month_dir, day_file)\n",
|
||||||
|
" new_day_file = day_file.zfill(2) # add leading zero to day file\n",
|
||||||
|
" #print(f\"Would have renamed Day folder from {os.path.join(year_path, month_dir, day_file)} to {os.path.join(year_path, new_month_dir, new_day_file)}\")\n",
|
||||||
|
" os.rename(day_path, os.path.join(year_path, new_month_dir, new_day_file))"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "base",
|
||||||
|
"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.9.12"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user