Skip to content

Instantly share code, notes, and snippets.

@jihyeonRyu
Last active March 27, 2018 23:18
Show Gist options
  • Save jihyeonRyu/e9684a46d0c5a69f794eb7e9b4a88f6b to your computer and use it in GitHub Desktop.
Save jihyeonRyu/e9684a46d0c5a69f794eb7e9b4a88f6b to your computer and use it in GitHub Desktop.
classify files by name
#!/bin/bash
# filename: aaa-01.jpg, bbb-01.jpg
for file in *.jpg ; do
arr=(${file//-/ })
dir=dir/${arr[0]}
[[ -d $dir ]] || mkdir -p "$dir"
mv "$file" "$dir"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment