Quantcast
Channel: Evilprofessor.co.uk » bash
Viewing all articles
Browse latest Browse all 3

Move a file to a subdirectory of the same name

$
0
0

A quick bash one liner to create and move a set of files in a directory to a sub-directory of the same name:


IFS=$'\n'; for i in `find . -maxdepth 1 -type f`; do echo "$i"; dir=${i%.*}; \
echo "$dir"; mkdir "./$dir"; mv "./$i" ./"$dir"/; done;

If you know a better way please post in the comments :)


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images