Move all photos from Google takeout into one directory
gist.github.com
gist.github.com
mkdir photos
mv -v **/*.jpg **/*.mp4 photos
Bash: shopt -s globstar
mkdir photos
mv -v **/*.jpg **/*.mp4 photos
But I think I'd prefer them in a directory based on the EXIF date in the photo anyway:Zsh:
for i in **/*.jpg; do
date=$(exif $i --machine-readable --tag=0x9003 | head -c 10 | tr : -)
if [[ -n $date ]]; then
mkdir -p $date
mv -v $i $date
else
mkdir -p Unknown
mv -v $i Unknown
# (Check other EXIF values, e.g. DateTimeOriginal.)
fi
doneI think you could achieve the same result with just the find command:
`find ./takeout -iname “.jpg” -exec mv {} newdir`
If you're not using Windows, you should probably learn to use some basic shell commands.
Also, line 19 has a bug.
Also, readdir('foo', {withFileTypes: true}) will return a list of directory entries so you can check the type without doing a stat. Also, sync versions are easier.
fs.readdirSync(DOCS_DIR, {withFileTypes: true}).forEach((file) => {
if(file.name.startsWith('.') || !file.isDirectory()){ return; }
...
}); import fs from 'fs';
import path from 'path';
copyMedia('Takeout');
function copyMedia(dir) {
fs.readdirSync(dir, {withFileTypes: true}).forEach((file) => {
if (file.isDirectory()) {
copyMedia(path.join(dir, file.name));
} else {
if (file.name.toLowerCase().endsWith('.jpg') || file.name.toLowerCase().endsWith('.mp4')) {
fs.cpSync(path.join(dir, file.name), path.join('photos', file.name));
}
}
});
}
It uses copy instead of move, but it's fine. find takeout -name ".jpg" -exec mv {} dest_dirNot much more than is wrong with sending a nuclear-powered aircraft carrier to kill a mosquito
> Is it a rule that everyone must know linux commands?
Unix, and yes. Every system around you is built on it or something derived from it (either literally or in design).
Also, no not every system around me requires me to learn unix, I can use my phone, microwave or even my gaming laptop(windows) without ever opening CLI. Unless Im at work or am I tinkering with my PI4s I don’t even have to touch CLI or even think about a unix command.
Sure, a Linux one liner might be “easier” to someone who knows Linux… but that doesn’t mean it’s “wrong.”
The goal was to make a script in quick time and I'm comfortable with nodejs that's why I chose it.
ls -Recurse -Filter *.jpg | mv dest_dirWould work on Windows, would work on *nix if change it to
gci -Recurse -Filter *.jpg | move dest_dirI think most cameras get to IMG_9999 and cycle back to IMG_0000