Skip to content

Instantly share code, notes, and snippets.

@johnsosoka
Created August 28, 2023 03:05
Show Gist options
  • Select an option

  • Save johnsosoka/294ef1364441a131848e93f6fb215138 to your computer and use it in GitHub Desktop.

Select an option

Save johnsosoka/294ef1364441a131848e93f6fb215138 to your computer and use it in GitHub Desktop.
desktop/downloads file cleanup
#!/bin/bash
# Define the Desktop path
DESKTOP_PATH="/Users/john/Desktop"
DOWNLOADS_PATH="/Users/john/Downloads"
# Path for Backup Dirs
BACKUPS_PATH="/Users/john/backups"
# Get the current date in YYYY-MM-DD format
DATE=$(date +%Y-%m-%d)
# Create Folders for Backing Up
DESKTOP_BACKUP_PATH="${BACKUPS_PATH}/${DATE}/desktop"
DOWNLOADS_BACKUP_PATH="${BACKUPS_PATH}/${DATE}/downloads"
# Create a new directory with the current date
echo "Creating backup destination directories..."
mkdir -p "${DESKTOP_BACKUP_PATH}"
mkdir -p "${DOWNLOADS_BACKUP_PATH}"
# Move all files from Desktop to the new directory
mv -v "${DESKTOP_PATH}/"* "${DESKTOP_BACKUP_PATH}"
mv -v "${DOWNLOADS_PATH}/"* "${DOWNLOADS_BACKUP_PATH}"
echo "All files from ${DESKTOP_PATH} have been moved to ${DATE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment