General Category > Blogs

Linux programs and Bash scripts to consolidate photos and begin a slideshow

<< < (2/3) > >>

Dragon:
Another thing that might be helpful if you're trying to upload to Google Photo with drag-and-drop onto an album page... you can drag a folder onto it to upload the whole folder, but it doesn't seem to pick up anything more than one level deep. Also, you can't just upload a zip file there. You could onto Google Drive, but not Google Photos. If you have a bunch of zip files that were created for storing a photos from a single directory, you might want to extract them all into the same folder. If they are in multiple levels of directories, and you're confident that you don't have duplicate filenames for what are actually different photos, you could run a command like this to grab all the readable files from 2 levels down or more and put it up on the current directory:


--- Code: ---find ./ -mindepth 2 -readable -type f -exec mv {} ./ \;
--- End code ---

Want to try this out with a prompt, try the ok option to be asked for each file:


--- Code: ---find ./ -mindepth 2 -readable -type f -ok mv {} ./ \;
--- End code ---

Dragon:
Have a list of filenames (even if there are extra line spaces in between) to move and want something to move them quickly? This simple one-liner worked great for me and is easy to understand, as long as you know that those are back-ticks, not single-quote marks.


--- Code: ---mv `cat /tmp/list.txt` /app/dest/
--- End code ---
source = https://unix.stackexchange.com/questions/115734/move-file-by-list-in-file-with-leading-whitespace

Dragon:
Need to reorganize some of those automatically created folders that Google exports with takeout.google.com?


--- Code: ---
#!/bin/bash
# Run rsync then remove files through multiple folders like so:
# rsync -av Photos\ from\ 2007/* 2007/ && rm -r Photos\ from\ 2007

for YEAR in {1985..2021}; do
        if [ -d "Photos from $YEAR" ]; then
                for NUM in {0..9}; do
                        if [[ $(ls -A Photos\ from\ $YEAR/$NUM*) ]]; then
                                rsync -av Photos\ from\ $YEAR/$NUM* $YEAR/ && rm -r Photos\ from\ $YEAR/$NUM*
                        else
                                echo "Skip $NUM"
                        fi
                done
                for LTR in {A..Z}; do
                        if [[ $(ls -A Photos\ from\ $YEAR/$LTR*) ]]; then
                                rsync -av Photos\ from\ $YEAR/$LTR* $YEAR/ && rm -r Photos\ from\ $YEAR/$LTR*
                        else
                                echo "Skip $LTR"
                        fi
                done
                rsync -av Photos\ from\ $YEAR/* $YEAR/ && rm -r Photos\ from\ $YEAR
        else
                echo "A directory called 'Photos from $YEAR' doesn't exist."
        fi
done


--- End code ---

Dragon:
I found out about a program called fdupes to find duplicate files on Linux. It just runs on command line, but seems pretty quick and has some convenient options for deleting the duplicates with or without prompts. Here's the first two commands for installing and scanning the Pictures directory.


--- Code: ---sudo apt-get install fdupes
fdupes -r ~/Pictures

--- End code ---

The default functionality is just to list the duplicates in groups. The '-r' option is for recursive checks in subdirectories. Including the '-d' option will prompt the user to save 1 or more file while deleting the other duplicates. There is also the '--noprompt' option, which is for deleting files without asking the user. 

Dragon:
I've been using fdupes on Linux for a couple days now. Very nice, simple process for the most part. Another cool thing is that fdupes is available for Mac via HomeBrew. (https://formulae.brew.sh/formula/fdupes)

I'd prefer if it had built-in functionality to have a preferred directory to preserve the files when deleting duplicates, but that's my only complaint. Overall, still better than others methods I've used.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version