Last active
November 12, 2023 17:38
-
-
Save CristianAbrante/6d0ceef9666b57a9cb64f297be94fe20 to your computer and use it in GitHub Desktop.
Script to copy RAW Niko photos to a folder in the Desktop and make it easier to upload them to Lightroom
This file contains hidden or 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
| #!/bin/zsh | |
| # This is a script to copy all .NEF files from a Nikon camera to a | |
| # folder and make it easy to import it to Lightroom. | |
| # How to use: | |
| # ./copy-photos.sh | |
| # Set the source and destination directories | |
| # Directory of the camera | |
| src_dir="/Volumes/T7/111D3500" | |
| # Directory where the photos will be copied | |
| dest_dir="/Users/cristianabrante/Desktop/raw-photos" | |
| # Check if the destination directory exists, if not, create it | |
| if [ ! -d "$dest_dir" ]; then | |
| mkdir -p "$dest_dir" | |
| fi | |
| # Function to generate a random string | |
| generate_random_string() { | |
| uuidgen | tr '[:upper:]' '[:lower:]' | cut -c 1-8 | |
| } | |
| # Find all .NEF files in subfolders and copy them to the destination directory | |
| find "$src_dir" -type f -name "*.NEF" | while read nef_file; do | |
| # Extract filename without extension | |
| filename=$(basename -- "$nef_file") | |
| filename_without_ext="${filename%.*}" | |
| # Generate a random string | |
| random_string=$(generate_random_string) | |
| # Create the new filename | |
| new_filename="${filename_without_ext}_${random_string}.NEF" | |
| # Copy the file to the destination directory with the new name | |
| cp "$nef_file" "$dest_dir/$new_filename" | |
| echo "Copied $nef_file to $dest_dir/$new_filename" | |
| done | |
| echo "All .NEF files have been copied!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment